lua-users home
lua-l archive

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


2011/6/21 James Graves <james.c.graves.jr@gmail.com>:
>
> There's a few things wrong with that function.  Here's the corrected
> version (of what I think you intended):
>
> function traverse_table(t)
>  if t and type(t) == "table" then
>     for k=1,#t do
>        if type(t[k]) == "table" then
>           print("a table")
>           traverse_table(t[k])
>        else
>           print("not a table")
>        end
>     end
>  else
>     print("not a table")
>  end
> end
>

Arg... I told you it was a silly question :-)

Thank you all for your quick answers.

Best,

-- 
Christophe