[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [propsal] improve to table.concat?
- From: Xavier Wang <weasley.wx@...>
- Date: Tue, 11 Oct 2011 16:51:35 +0800
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 :)