lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Can someone just confirm my thoughts that the first example is always wrong, and the second will always work.

Using Lua 5.2 if that matters.

Thanks,
Kevin

Example 1:

> t = {}
> t[#t+1], t[#t+1] = 1, 2
> for k,v in pairs(t) do print(k,v) end
1	1 

Example 2:

> t = {}
> t[#t+1], t[#t+2] = 1, 2
> for k,v in pairs(t) do print(k,v) end
1	1
2	2