I was reading through some free models and I saw this “syntax”. I’ve never seen this before but I managed to figure out what it does. What is this called and why does it work? One thing’s for sure, it’s ugly.
-- What I found
script.Name, script.Parent='Foo', workspace.Terrain
-- What seems to be identical
script.Name = 'Foo'
script.Parent = workspace.Terrain
They’re (I think are called) multiple assignments. They’re basically the same in this context but not when using function calls or varargs (...) at the end. If a function call returned multiple values, it assigns to its respect variable in the order when you want to assign them.
For example:
local function c()
return 0, 1
end
locale a, b = c()
print(a, b) --> 0 1
It’s not called “tuples” despite Roblox documentation saying so. In Lua(u), if a function returns multiple values; they return multiple values; they’re not put together as a single data structure; they’re separate values.
Let me quote the part of @TheEdgyDev’s post that I linked earlier.