if i have a table like this
t = {"h","i"}
how do i turn that into
"hi"
?
[lua] question on tables
Started by tom2018, Mar 23 2013 12:15 PM
1 reply to this topic
#1
Posted 23 March 2013 - 12:15 PM
#2
Posted 23 March 2013 - 12:19 PM
Two methods.
Harder way, but with more flexibility:
Easier way, less flexibility, but perfect for your purposes.
In the future, you can also use an optional separator with table.concat if you want.
Harder way, but with more flexibility:
local str = '' for i=1, #t do str = str .. t[i] end print(str) --> hi
Easier way, less flexibility, but perfect for your purposes.
local str = table.concat(t) print(str) --> hi
In the future, you can also use an optional separator with table.concat if you want.
local str = table.concat(t, ',') print(str) --> h,i
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











