[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Multiple assignment, numeric table keys
- From: Kevin Martin <kev82@...>
- Date: Wed, 12 Dec 2012 11:16:21 +0000
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