API Reference › Builtin functions › none
function

none

none() -> option

The empty option — a missing value with no sentinel. Return it when there is nothing to give: no target, an empty slot, a lookup that missed. The caller distinguishes it from some with is_none / is_some, or supplies a default with unwrap_or.

Example

program Slots {
  function held(slot: int) -> option {
    if slot < 0 { return none() }
    return some(slot)
  }
  test "none is empty" {
    expect_eq(is_none(held(0 - 1)), true)
  }
}
← All symbols