On Mon, Oct 20, 2014 at 1:44 PM, Coda Highland <chighland@xxxxxxxxx> wrote: > On Mon, Oct 20, 2014 at 1:41 PM, Eduardo Barthel <edub4rt@xxxxxxxxx> wrote: >> I see that unpack uses the length operator again, but shouldn't luajit >> behave like lua in such cases? > > It DOES behave like Lua. You're invoking undefined behavior by using a > table with a nil in it. Undefined behavior has NO guarantees about its > behavior. > > Even Lua will have different behaviors there depending on how you > construct that table. It's NOT guaranteed that #a will always return 3 > for the table you've quoted. > > /s/ Adam Case in point, using stock Lua 5.2: b = { } b[1] = 1 b[2] = nil b[3] = 2 print(#b) -- outputs 1, even though b contains { 1, nil, 2 } /s/ Adam