← All examples

Keyword fn

A keyword may name a function, reached by path, never bare: bare to is the conversion and bare true the boolean, so these are my.to[], my.true[].

keyword_fn.zg
# A keyword may name a function, reached by path, never bare (2026-09-19):
# bare `to` is the conversion and bare `true` the boolean, so these are `my.to[]`, `my.true[]`.
fn to [] -> int32 { return 5; }
fn true [] -> int32 { return 1; }
MAIN {
    let 'x' := my.to[];
    let 'y' := my.true[];
    std::print.useful['x', " ", 'y', newln];
}
Output
5 1