Optional
Optional: None, Some, print, take
Functions: operator==, print, println
enum Optional<T>
A value that may be absent.
None
NoneSome
Some(T value),void print(OutputStream& stream)Writes the value, or null if there is none, to the given stream.
take
T? take()Moves the optional out, leaving None in its place. Always call this
on a pointer ((&opt).take()): a plain
opt.take() unwraps and takes the payload instead, or fails
to compile if the payload has no take() method.
operator==
bool operator== <T: Comparable>(T?& a, T?& b)Returns true if both optionals are equal.
bool operator== <T: Comparable>(T?& a, T& b)Returns true if the optional holds a value equal to b.
bool operator== <T: Comparable>(T& a, T?& b)Returns true if the optional holds a value equal to a.
bool operator== <T: Comparable>(T&? a, T& b)Returns true if the optional borrow is non-null and borrows a value equal to b.
bool operator== <T: Comparable>(T& a, T&? b)Returns true if the optional borrow is non-null and borrows a value equal to a.
void print<T: Printable>(T?& optional)Prints the given value.
void print<T: Printable>(T&? optional)Prints the given optional borrow.
println
void println<T: Printable>(T&? optional)Prints the given optional borrow followed by a newline.