Option<T> class abstract

Option is a type that represents either having a value (Some) or not having a value (None).

Implementers
Available Extensions
Annotations
  • @sealed

Constructors

Option()
const

Properties

hashCode int
The hash code for this object.
no setterinherited
isNone bool
Returns true if the option is None.
no setter
isSome bool
Returns true if the option is Some.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

and<U>(Option<U> optb) Option<U>
Returns None if the option is None, otherwise returns optb.
andThen<U>(Option<U> f(T value)) Option<U>
Returns None if the option is None, otherwise calls f with the wrapped value and returns the result.
expect(String msg) → T
Returns the contained Some value, consuming the this value.
filter(bool predicate(T value)) Option<T>
Returns None if the option is None, otherwise calls predicate with the wrapped value and returns:
iter() Iterable<T>
Returns an iterable over the possibly contained value.
map<U>(U op(T value)) Option<U>
Maps an Option<T> to Option<U> by applying a function to a contained value.
mapOr<U>(U defaultValue, U f(T value)) → U
Returns the provided default (if None), or applies a function to the contained value (if Some),
mapOrElse<U>(U defaultF(), U f(T value)) → U
Computes a default function result (if None), or applies a different function to the contained value (if Some).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
okOr<E>(E err) Result<T, E>
Transforms the Option into a Result, mapping Some(v) to Ok(v) and None to Err(err).
okOrElse<E>(E err()) Result<T, E>
Transforms the Option into a Result, mapping Some(v) to Ok(v) and None to Err(err()).
or(Option<T> optb) Option<T>
Returns the option if it contains a value, otherwise returns optb.
orElse(Option<T> f()) Option<T>
Returns the option if it contains a value, otherwise calls f and returns the result.
some() → T?
Converts from Option<T> to T?.
toString() String
A string representation of this object.
inherited
unwrap() → T
Returns the contained Some value, consuming the this value.
unwrapOr(T defaultValue) → T
Returns the contained Some value or a provided default.
unwrapOrElse(T op()) → T
Returns the contained Some value or computes it from a closure.
xor(Option<T> optb) Option<T>
Returns Some if exactly one of this, optb is Some, otherwise returns None.
zip<U>(Option<U> other) Option<Tuple2<T, U>>
Zips this with another Option.

Operators

operator ==(Object other) bool
The equality operator.
inherited