A colon (:) inside a type means those are the arguments that the type expects.
Example:
PrintWhat <string: "Hello, World!", "Goodbye, world."> -- Expects one of the two strings.
Use case example:
PrintWhat = "Hello, World!" -- Is expected (Accepted)
--
PrintWhat = "Goodbye, world." -- Is expected (Accepted)
--
PrintWhat = "Lorem Ipsum" -- Not expected (Rejected)
A (): after a function type indicates the return type.
Example:
Callback <function(): string> -- The function returns a string when called.
Use case example:
Callback = function(Input)
print(Input)
end)
A (): void after a function type indicates it does not return anything.
Example:
Callback <function(): void> -- The function returns nothing when called.
Use case example:
Callback = function()
print("Hello, World!")
end)
<type or type> means the argument can accept either type.
Example:
Default <number or table> -- Accepts either a number or a table as the default value.
Use case example:
Default = 5 -- Accepted
--
Default = {"Hello", "World"} -- Accepted
--
Default = true -- Rejected (not a number or table)
A : followed by a type indicates a return value and its type.
Example:
:GetFruitSize(<string>: number) -- Returns the size of the specified fruit.
:GetState(: boolean) -- Returns whether the window is currently visible or not.
Use case example:
:GetFruitSize("Apple") -- Returns the size as a number of an apple
--
:GetState() -- Returns the state as a boolean