strjoin accepts one string and then a variable number of arguments. I’m looking for a way to take a table with a variable number of arguments and use each item in the table as another argument.
local myTable = {
'a',
'b',
'c',
}
-- This is what I want except that I don't want to hard code
-- a specific number of parameters
local myString = strjoin(' ', myTable[1], myTable[2], myTable[3])
Use the unpack function:
Newer versions of Lua place the unpack function in the table module:
This doesn’t answer your question directly, but as lhf pointed out, the following is much more efficient: