KScript docs
EN

fn fields and methods

Functions: lambdas fn(x) => $x * 2 and <fn> functions.

A field is a plain fact about the value, read with a dot and no brackets: $value.name. A method takes arguments or does work, and is called with ->: $value->name(arguments), or with the value piped in: $value |> name(arguments).

From KScript.Core

#fn->call(args...) → any

Calls the function with these arguments.
Example
<let name="area" value="fn(width, height) => $width * $height" />
<!-- 42, because call gives 6 to width and 7 to height. -->
<echo>{ $area->call(6, 7) }</echo>
<!-- 'Hello Ada'. The brackets end the fn: without them, |> call('Ada') would be part of its body, and nothing would call it. -->
<echo>{ (fn(name) => 'Hello ' + $name) |> call('Ada') }</echo>
$area = fn(width, height) => $width * $height
// 42, because call gives 6 to width and 7 to height.
echo $area->call(6, 7)
// 'Hello Ada'. The brackets end the fn: without them, |> call('Ada') would be part of its body, and nothing would call it.
echo (fn(name) => 'Hello ' + $name) |> call('Ada')

Methods from any