lua-users home
lua-l archive

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


Op Sat, 12 Dec 2020 10:20:52 +0100 schreef Spar <developspartv@gmail.com>:

"[3] = 30" is overwritten by next sequential integer which is 3 as well. That's why you see 3 = 40.

t3 table has different order because in PUC Lua expressions in brackets ([3], [a], ["key"]) always goes to hash part. This is not true in LuaJIT btw.

Ah, I overlooked the Table Constructors paragraph [1] in the reference manual.
I wasn't able to find more about it in the fourth edition of PIL.

The sentence "Fields of the form exp are equivalent to [i] = exp, where i are consecutive integers starting with 1; fields in the other formats do not affect this counting." applies to the 't2' case, like you said.

Thanks.

-- Jasper

[1] http://www.lua.org/manual/5.4/manual.html#3.4.9