Functions
You can make a simple function block with brace brackets.
{ print "Hello world!" }
{
print "Hello world!"
print "DreamTode is the future!"
}
When a function is expected, you can leave off the brackets.
print "Hello world!"
Parameters
The =>
operator gives a function some parameters.
[a, b] => { return a + b }
You can leave off the brace brackets and return
for single-line functions.
[a, b] => a + b
The ->
operator does the same thing, but the function won't return anything when called.
[name] -> print "Hello {name}"
Calling
To call a function... put an array of arguments after it.
([a, b] => a + b)(3, 2)
If a function takes no arguments, you can call it with an empty array.
{ print "Hello world!" }()
Alternatively, you can use the :
operator to place the first argument in front of the block.
(3):([a, b] => a + b)(2)
Last updated
Was this helpful?