Option<T> class
sealed
Represents an optional value of type T
.
An Option is either:
Adapted from Rust's Option
, see more here:
https://doc.rust-lang.org/std/option/index.html
- Implementers
- Available extensions
- Annotations
-
- @immutable
Constructors
- Option.none()
-
Shortcut for None.new.
constfactory
- Option.some(T value)
-
Shortcut for Some.new.
constfactory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
asNullable(
) → T? -
Available on Option<
Returns Some.value orT> , provided by the OptionConvenience extensionnull
for None. -
map<
R> (R mapper(T)) → Option< R> -
Available on Option<
Maps an OptionT> , provided by the OptionConvenience extension -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
unwrapOr(
T defaultValue) → T -
Available on Option<
Returns Some.value ifT> , provided by the OptionConvenience extensionthis
is a Some. Otherwise, returnsdefaultValue
(when None). -
unwrapOrElse(
T defaultFn()) → T -
Available on Option<
Returns Some.value ifT> , provided by the OptionConvenience extensionthis
is a Some. Otherwise, calls and returns the result ofdefaultFn
(when None).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited