substituting 'print(i,v)' instead of 'print(v)' gives 2,10; 3,20; ...
function iter(t)
local i = 1
return function()
local val = t[i]
if val == nil then return nil end
local icurrent = i
i = i + 1
return icurrent ,val
end
end
for i,v in iter {10,20,30} do print(i,v) end
(Thanks for the faq)
-- Joe
On Tue, Dec 22, 2009 at 12:09 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
http://www.batbytes.com/luafaq/
Version 1.5 answers a few new questions, like:
1.37 How does module() work?
1.38 What are weak tables?
1.39 What is the difference between the various ways to quote strings?
7.7 What am I allowed to do with the Lua stack and its contents in my
C functions?
7.8 What is the difference between userdata and light userdata?
And generally cleaned up some entries (thanks to spir for pointing out
problem with newproxy example, and Dirk Feytons for new C API
material)
Have a read, and please be picky; this needs to be solid as possible
if people are going to be leaning on it.
steve d.