Copy of Function

Use functions to modularize shared logic such as data extraction and generation.

Argument Order

Arguments in knot can be matched through punning rather than by position. Use the parameter explosion function call modifier (#) to use named arguments and enable punning.

func addTogether(lhs: number, rhs: number) -> lhs + rhs;

addTogether(20, 4); // 24

let rhs = 4;

addTogether(30, rhs: 40);
// ERROR: cannot mix positional arguments with named arguments

addTogether#(30, rhs: 40);
// ERROR: must name each argument when using explosion modifier

Last updated