Trailing parameters can declare defaults, which makes them optional and nameable at the call site:
1 2 3 4 5 6
fn greet[name, greeting = 'hello']
return '`greeting`, `name`'
log[greet['crow']]
log[greet['crow', 'hey']]
log[greet['crow', greeting = 'welcome']]expected output — from the book, verified by crow test --book
hello, crow
hey, crow
welcome, crowThe rules are exactly three:
You'll use this constantly with builtins: fmt[x, decimals = 2],
sort[df, 'age', desc = true], sum[m, axis = 0]. It's the same
mechanism everywhere — there is no separate "keyword argument" system for
builtins versus your functions.