option

Generated by tinox doc

tinox.core.option, bundled with the compiler and also available as a standalone tinox-central package.

Some none

import tinox.core.option
class Main
{
    fnc main() -> Int32
    {
        const found: Option<Int64> = Option<Int64>::some(42)
        const missing: Option<Int64> = Option<Int64>::none()
        println("found.isSome() = " + found.isSome().toString())
        println("found.unwrap() = " + found.unwrap().toString())
        println("missing.unwrapOr(-1) = " + missing.unwrapOr(-1).toString())
        return 0
    }
}

@Errorclass NoneError

* Thrown by `Option.unwrap` on a None value.

Fields

messageString

class Option<T>

* Represents an optional value of type T. * Uses a List<T> internally to avoid requiring a zero value for T.

Fields

valuesList<T>

Methods

fn none() → Option<T>
fn some(value: T) → Option<T>
fn isSome() → Bool
fn isNone() → Bool
@Throwsfn unwrap() → T
fn unwrapOr(defaultValue: T) → T
fn map(transform: fnc(T) -> U) → Option<U>
fn andThen(transform: fnc(T) -> Option<U>) → Option<U>
fn orElse(fallback: fnc() -> Option<T>) → Option<T>