quick newbie question, i havent seen this being used often. can anyone explain what the (...) refers to?
function Graph:newNode(...)
quick newbie question, i havent seen this being used often. can anyone explain what the (...) refers to?
function Graph:newNode(...)
So, the three dots are an ellipsis. In functions, they are used as a substitute to having named parameters. For example:
local function foo (...)
print(#{...})--8
for _,v in pairs({...}) do
print(v)
end
end
foo("thy","they","2",121,343,4323,"fbi","boo")
the ellipsis is particularly useful when you are sending a lot of arguments to a function, and instead of having to create a parameter for every single argument you have. For Example:
game.ReplicatedStorage.Remote.OnServerEvent:Connect(function(...)
local a = {...} --table of arguments
print(a[1],a[3],a[2],a[6],a[9])
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Check out eLunate's answer on this: https://scriptinghelpers.org/questions/59764/what-does-all-these-different-types-of-functions-do#58105