--- id: fn-ok name: ok category: builtins kind: builtin tokens: ok sig: ok(v) -> result tip: Wrap a success payload in a result — the happy half of try/else. order: 12 --- Wraps a success value in a result — the value type a fallible function returns. A result carries either a success payload (this) or a failure message (from err), and a caller recovers it with try/else or classifies it with is_ok / is_err. A function that can fail declares -> result and returns ok(value) on the happy path. The payload is any i32-width scalar — int, fixed, bool, or entity. Parameters: - `v` — the success payload ```ludic program Parse { function to_digit(c: int) -> result { if c >= 48 and c <= 57 { return ok(c - 48) } # '0'..'9' return err("not a digit") } test "ok carries the parsed value" { let d = try to_digit(55) else { 0 } # '7' -> 7 expect_eq(d, 7) } } ```