So I have something like this:
local function test (...)
--something here
end
How do I loop through all the parameters sent into a table? So, if I sent 3 parameters: "ok", "yeet", 0
, the result would be {“ok”, “yeet”, 0}
So I have something like this:
local function test (...)
--something here
end
How do I loop through all the parameters sent into a table? So, if I sent 3 parameters: "ok", "yeet", 0
, the result would be {“ok”, “yeet”, 0}
You mean something like this?
local function Test(...)
return {...}
end
local ReturnedTable = Test("ok", "yeet", 0)
print(typeof(ReturnedTable), ReturnedTable)
Result:
yeah, something like that, but is it possible to put all the values into a table inside the function test? would table.pack work?
local function Test(...)
local Table = {...}
--// You can do something with the table here
return Table
end
didn’t notice it was that easy =/ lol
Alternatively,
function a(...)
for n = 1, select("#", ...) do
print( (select(n, ...)) )
end
end
a(1, 2, 3)
The extra parens matter here, try it without to see what happens
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.