Skip to content

Anonymous Functions

Ferret supports function literals with =>.

let square = (x: i32) => x * x
let value = square(5)

Block form:

let describe = (x: i32) => {
if x > 0 {
return "positive"
}
return "zero-or-negative"
}

You can store function values in maps and call them later.