Functions
Anonymous Function Declaration
Declaring functions in Loop is easy, you just use the fn
keyword accompanied by it's arguments and function body. For example:
If you'd like to call a function again (which is it's primary use-case of course). Then you can assign a function to a variable, which is as easy it sounds.
Named Functions
Named functions differ from anonymous functions in that it is possible to recursively call them. Creating a named function is easy and just requires providing a name to the fn
keyword.
Closures
"A closure is a record storing a function together with an environment" - Wikipedia
Because functions are considered first-class in Loop it means they can also contain their own environment. Creating a function automatically creates an environment for that function. Take this as an example:
Last updated