Skip to main content

Optional Parameters

Optional parameters are parameters that may be omitted when calling a function. They are declared by adding a question mark (?) after the parameter name.

fn Function1(x, y?) { }
fn Example() {
// omit `y` parameter because it is optional
Example(1)
}

Optional subject parameters

Subject parameters may also be declared as optional.

fn this?.Function1(x, y) { }

Optional subblocks

The subblock may be made optional by wrapping its parameter list in a | and |? pair.

fn Function1() |name, age|? {
delve() // this will simply do nothing if `delve` is undefined
}