tags:

views:

73

answers:

2

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])
+8  A: 

Use the unpack function:

local myString = strjoin(' ', unpack(myTable))
Judge Maygarden
+4  A: 

Use table.concat instead of strjoin.

lhf
While technically you are correct, your answer was not chosen because I am looking for a solution I can also apply to some other similar functions.
Asa Ayers