lua-users home
lua-l archive

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


On Sat, Dec 27, 2008 at 12:35:53PM -0500, G.H. wrote:
> 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

This is wrong, it will compare only the first table element:

  Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
  > a={1,2}
  > b={1,3}
  > = #a == #b and (unpack(a) == unpack(b))
  true

Cheers
-- 
Enrico Tassi