Skip to content

06 · Functions

Required named arguments

Parameters after * must be supplied by their external labels. Defaults can still be omitted. This contract follows methods, exported declarations and typed function values; passing the function as a callback does not remove the requirement.

On this page

Parameters after * must be supplied by their external labels. Defaults can still be omitted. This contract follows methods, exported declarations and typed function values; passing the function as a callback does not remove the requirement.

Complete example

Required named arguments.

named_required.zolo
Playground
// Required names make call sites readable, including through a function value.

fn transfer(*,from:int,to:int,amount:int=1)->int=from-to+amount
let send=transfer
print(send(from:10,to:3,amount:2))

// Earlier parameters may remain positional; defaults still belong to the callee.

fn advance(start:int,*,by:int=1)->int=start+by
print(advance(7,by:2))

Rules and behavior

Function parameters and lambdas · Documentation

From a checkout of the repository:

zolo examples/features/named_required.zolo

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br