I've seen this very often;
function co(...)
-- do stuff
end
I'm focusing on the parameter, like why do you use it?
I've seen this very often;
function co(...)
-- do stuff
end
I'm focusing on the parameter, like why do you use it?
It allows you to take any amount of variables as a tuple.
function VariadicFunction(...)
local Arguments = {...} --contain tuple thing
local n = 0;
for i, v in pairs(Arguments) do
if not tonumber(v) then error("argument "..i..": not a number") end
n = n + v;
end
return n
end
VariadicFunction(4,5,6,7,8,9,10) --gives you 4+5+6+7+8+9+10, too lazy to calculate heehee hoohoo
Wow! Thanks
This discussion is preserved as it was. New answers, comments, and votes are closed.
7 comments
try this: https://www.lua.org/pil/5.html
try this: https://www.lua.org/pil/5.html
try this: https://www.lua.org/pil/5.html
It says nothing about using (...), in a parameter.
And ROBLOX LUA, and LUA are two different languages.
It's the same base language, so most stuff that you can do in Lua will work in Roblox. Roblox's Lua is just adapted to the platform and the game world.
I presume the ellipses is just a wildcard? If you could give a script example I might be able to answer this.