how do you get a table like:
letters = {"a", "b", "c"}
to
"abc"
turning table data into one string
Started by ETHANATOR360, Mar 04 2013 11:32 AM
5 replies to this topic
#1
Posted 04 March 2013 - 11:32 AM
#2
Posted 04 March 2013 - 11:35 AM
local output = ""
local mytable = {"a", "b", "c"}
for i = 1, #mytable do output = output .. mytable[i] end
print(output)
You want me to explain?
#3
Posted 04 March 2013 - 11:36 AM
Nicer way:
Only works with tables with numeric indices though.
str = table.concat(letters) print(str)
Only works with tables with numeric indices though.
#4
Posted 04 March 2013 - 11:37 AM
Now that's why YOU are the "Lua God" and I am the "Scripter"
#5
Posted 04 March 2013 - 11:40 AM
usage is table.concat("string","spacer")
spacer can be anything separating the table elements (including nil or "")
spacer can be anything separating the table elements (including nil or "")
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users












