self explanitory really
![]()
whats the point of this notation
why do people do it
what makes it useful
thing:() -> ()
???
help
self explanitory really
![]()
whats the point of this notation
why do people do it
what makes it useful
thing:() -> ()
???
help
A function that returns a function?
That is a type. Specifically, a type for a function that takes zero inputs and creates zero outputs.
Read more about it here:
The full code would most likely be:
type thing = () -> ()
Or (this would be in a module; the type would be used in another script):
export type thing = () -> ()
For an average person, you generally wouldn’t need to define the type like this since it is very simple. In most cases, you could just do:
local function thing(): ()
end
Or generally:
local function Function(input: InputType): (outputs: OutputType)
end
-- This is the equivalent to:
type FunctionType = (InputType) -> (OutputType)
local Function: FunctionType = function()
end
There’s some more info I could talk about, but it would probably be best if you learn the basics of type checking first, since it isn’t a super easy topic.
Sorry for so many edits.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.