Posted 06 August 2014 - 04:55 AM
Simple question, but I see no simple answer…
I have a 1D table of arguments I want to use for a function, however I don't know how many args there are. So how would I call the function with a variable number of args?
Heres an example:
Please Note: Clearly this is a terrible way to approach the code I put in the example, but that code is a major simplification of my real use for this.
I have a 1D table of arguments I want to use for a function, however I don't know how many args there are. So how would I call the function with a variable number of args?
Heres an example:
function fn(...)
for i = 1, #arg do
print(arg[i])
end
end
x = {"I", "want", "to", "print", "all", "these", "things"}
fn(x) -- This obviously won't work...
Please Note: Clearly this is a terrible way to approach the code I put in the example, but that code is a major simplification of my real use for this.
Edited on 06 August 2014 - 02:58 AM