Functions
Syntax
To declare a function, just use the keyword func.
func greet() {
puts 'Hello'
}Print it:
puts greet // main@greetCall it:
greet() // Hello// todo
Arrow functions
A simple arrow function:
var greet = () => {
puts 'Hello'
}You can print greet out:
puts greet
// fn@abcd3458And call it:
One return expression, no brackets
More example:
Variadic function
A variadic function helps you to group multiple parameters to an array.
You also can pass parameters into a function call.
// todo
Notes
You cannot call a non-callable value.
A function name cannot be declared more than one time.
A function variable is immutable, so you cannot modify it.
Last updated
Was this helpful?