From what I’ve read so far, a tuple means that it returns multiple values. And if a method, which is a unique function to a specific object, accepts the tuple as an argument, which means it can accept multiple values. I’m just having a hard time understanding because wouldn’t that mean a tuple only applies to methods?
1 Like
Would a tuple apply to a table?
You ask if you can save a Tuple in a table?
Of course.
Tuples are a little different than tables. When you use table.unpack
, it returns a tuple. When entering arguments into a function, all the arguments together are considered a tuple. Example:
myFunction(variable1, variable2, variable3)
Another example:
local mytable = {"hi","bye"}
local tuple = table.unpack(mytable)
myfunction(tuple) --this is the same as myfunction("hi","bye")
1 Like
Another example of using tuples is when making variables. Sometimes you can make multiple variables at once. Here is an example:
local hi, bye, gm, gn, gtg = "hi", "bye", "gm", "gn", "gtg"
With the above code, each variable name is set to the corresponding value on the other side of the equal side. Variable hi is equal to “hi”, variable bye is equal to “bye”, and the same for the rest.
1 Like
Thanks a lot. I needed this lmao.
1 Like