lua-users home
lua-l archive

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


hi list :)

In Lua, to print a table is some how difficult: if you print it
direct, a useless string of table: address will print, use
table.concat, you can print a sequence easily:

local t = {1,2,3,4,5}
print(t) --> table: xxxxxxxx
print(table.concat(t, ",")) --> 1,2,3,4,5

but you can not use this way to print a hash table:

local t = {a:1, b:2, c:3}
print(table.concat(t, ',')) --> empty line

some, maybe table.concat can accept a second sep:
print(table.concat(t, ':', ',') --> a:1,b:2,c:3

this will give a easy way to print table.

thx :)