Some<T extends Object> class
Type Some<T>
is an Option
that contains a value.
You can construct a Some
using the Some()
constructor or by calling the
Option.some()
factory constructor. The advantage of using the factory
constructor on Option
is that it will yield a None
if the passed value
is null
, which can be helpful.
Constructors
- Some(T v)
-
Create a
Some
option with the given value.const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
props
→ List<
Object?> -
The list of properties that will be used to determine whether
two instances are equal.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- some → T
-
Wrapped value.
no setter
- stringify → bool?
-
If set to
true
, the toString method will be overridden to output this instance's props.no setterinherited
Methods
-
and<
U extends Object> (Option< U> optb) → Option<U> -
Returns None if the option is None, otherwise returns
optb
.inherited -
andThen<
U extends Object> (Option< U> op(T)) → Option<U> -
Returns
None
if the option isNone
, otherwise callsop
with the wrapped value and returns the result.inherited -
expect(
String msg) → T -
Unwraps an option, yielding the content of a
Some
.inherited -
filter(
bool predicate(T)) → Option< T> -
Returns
None
if the option isNone
, otherwise callspredicate
with the wrapped value and returns:inherited -
isNone(
) → bool -
Returns
true
if the option is aNone
value.inherited -
isSome(
) → bool -
Returns
true
if the option is aSome
value.inherited -
map<
U extends Object> (U op(T)) → Option< U> -
Maps an
Option<T>
toOption<U>
by applying a function to a containedSome
value. Otherwise returns aNone
.inherited -
mapOr<
U> (U op(T), U opt) → U -
Applies a function to the contained value (if any), or returns the
provided default (if not).
inherited
-
mapOrElse<
U> (U op(T), U def()) → U -
Maps an
Option<T>
toU
by applying a function to a containedT
value, or computes a default (if not).inherited -
match<
R> (R someop(T), R noneop()) → R -
Invokes either the
someop
or thenoneop
depending on the option.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
okOr<
E extends Object> (E err) → Result< T, E> -
Transforms the
Option<T>
into aResult<T, E>
, mappingSome(v)
toOk(v)
andNone
toErr(err)
.inherited -
okOrElse<
E extends Object> (E err()) → Result< T, E> -
Transforms the
Option<T>
into aResult<T, E>
, mappingSome(v)
toOk(v)
andNone
toErr(err())
.inherited -
or(
Option< T> optb) → Option<T> -
Returns the option if it contains a value, otherwise returns
optb
.inherited -
orElse(
Option< T> op()) → Option<T> -
Returns the option if it contains a value, otherwise calls
op
and returns the result.inherited -
toNullable(
) → T? - Returns an nullable that represents this optional value.
-
toString(
) → String -
A string representation of this object.
inherited
-
unwrap(
) → T -
Unwraps an option, yielding the content of a
Some
.inherited -
unwrapOr(
T opt) → T -
Returns the contained value or a default.
inherited
-
unwrapOrElse(
T op()) → T -
Returns the contained value or computes it from a closure.
inherited
-
when<
R> ({required R some(T), required R none()}) → R -
Invokes either
some
ornone
depending on the option.inherited -
xor(
Option< T> optb) → Option<T> -
Returns
Some
if exactly one ofthis
,optb
isSome
, otherwise returnsNone
.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited