While reading some of the api documentation for
DataStoreService | Roblox Creator Documentation and it’s members, particularly GlobalDataStore | Roblox Creator Documentation, I noticed that several functions said they returned the type of
Variant while others said they returned the type of
Tuple. However, when clicked, both links take you to the page for the type
My question is this:
Is there a difference between the
Tuple type? If there is a difference, is it an internal engine difference that won’t matter to me as I code? Should I treat them as the same?
October 6, 2021, 1:33pm
Variant could be considered
tuple is, not exactly, an unpacked table, also known as
You’re correct: Variant denotes any type. In the case of assert, the function will verify that the first argument is a truthy value (not false or nil) and return that value; otherwise, it will throw an error with an optional second argument for context.
-- Valid input
local Input = 5
Input = assert(type(Input) == "number" and Input, "number expected, got " .. type(Input))
print(Input) --> 5
-- Invalid input
local Input = "clam chowder"
Input = assert(type(Input) == "number" and Input, "number …
all kinds of values (
Tuple: multiple values taken as one if using