lua-users home
lua-l archive

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


G.H. wrote:
Unless t1 = {1,2,3} and t2 = {['a'] = 1, ['b']...} or t2 = {1,2,3, ...}
Such as they'll be rejected immediatly. But it isn't so useful anyway  :)

It's worth remembering that Lua (and the current implementation) doesn't actually guarantee two identical holey tables will have the same length.
So comparing lengths isn't a good shortcut unfortunately..

As an example running this on Lua 5.1:

local t1 = {1, 2, nil, 4, nil}
local t2 = {1, 2}
t2[4] = 4
print(#t1..", "..#t2)

will print: 2, 4

- Alex