Skip to content

Function declarations

Functions are declared with the func keyword.

The accepted parameters are declared in parentheses after the method name and are separated by commas.

The return type of the function is declared after the function name and is surrounded by angle brackets.

If there are variables outside the scope of the function with the same name as the parameters, they are ignored, so there is no shadowing, however for readability this is not recommended.

Functions cannot have side-effects and must return a value.


Example

func<number> add($x, $y) = {
    get $x + $y
}

func<string> concat($x, $y) = {
    get $x ~ $y
}