← All examples

Fallback type

A conversion's fallback takes the conversion's type: to.deci32['x'] otherwise 0 is a deci32 0, and so is 'y'.

fallback_type.zg
# A conversion's fallback takes the conversion's type (types.md: a bare literal takes its context's
# family): `to.deci32['x'] otherwise 0` is a deci32 0, and so is 'y'. Found by check claude, 2026-09-30.
MAIN {
    let 'x': deci64 = 3.141592653589793;
    let 'y' := to.deci32['x'] otherwise 0;
    let 'z' := to.int64['y' times 1000000] otherwise -1;
    let 'b': bin64 = to.bin64["not a number"] otherwise 0;
    std::print.stored['y', " ", 'z', " ", 'b', newln];
}
Output
0 0 0