lua-users home
lua-l archive

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


> I assume your question to be restricted to "pure Lua"
> scripting. So a 'crazy Moe' version could be:

> function compareTables(t1, t2)
>        return (#a == #b) and (unpack(t1) == unpack(t2))
> end

Sorry to disappoint you, but this would not work for two reasons:

1. Unpack ignores hash-part keys of the table.
2. More important, unpack(t1) == unpack(t2) compares only first
elements of the tables. It is equivalent to t1[1] == t2[1]. There is
no multi-argument equality operator, only assignment one.

Alexander.