Option$OptionMethodsExtension<T extends Object> extension
Methods
-
and<U extends Object>(Option<U> other)
→ Option<U>
-
Returns None if the option is None, otherwise returns
other
.
-
andThen<U extends Object>(Option<U> f(T))
→ Option<U>
-
Returns None if the option is None, otherwise calls f with the wrapped value and returns the result. Some
languages call this operation flatmap.
-
expect(String msg)
→ T
-
Returns the contained Some value if Some, otherwise throws a Panic.
-
filter(bool predicate(T))
→ Option<T>
-
Returns None if the option is None, otherwise calls predicate with the wrapped value and returns
Some(t) if predicate returns true (where t is the wrapped value), and
-
inspect(dynamic f(T))
→ Option<T>
-
Calls the provided closure with a reference to the contained value
-
isNone()
→ bool
-
Returns true if the option is a None value.
-
isSome()
→ bool
-
Returns true if the option is a Some value.
-
isSomeAnd(bool f(T))
→ bool
-
Returns true if the option is a Some and the value inside of it matches a predicate.
-
iter()
→ Iter<T>
-
Returns an Iter over the possibly contained value.
-
map<U extends Object>(U f(T))
→ Option<U>
-
Maps an this Option
-
mapOr<U>(U defaultValue, U f(T))
→ U
-
Returns the provided default result (if none), or applies a function to the contained value (if any).
-
mapOrElse<U>(U defaultFn(), U f(T))
→ U
-
Computes a default function result (if none), or applies a different function to the contained value (if any).
-
okOr<E extends Object>(E err)
→ Result<T, E>
-
Transforms the Option
-
okOrElse<E extends Object>(E errFn())
→ Result<T, E>
-
Transforms the Option
-
or(Option<T> other)
→ Option<T>
-
Returns the option if it contains a value, otherwise returns other.
-
orElse(Option<T> f())
→ Option<T>
-
Returns the option if it contains a value, otherwise calls f and returns the result.
-
unwrap()
→ T
-
Returns the contained Some value, consuming the self value.
-
unwrapOr(T defaultValue)
→ T
-
Returns the contained Some value or a provided default.
-
unwrapOrElse(T f())
→ T
-
Returns the contained Some value or computes it from a closure.
-
xor(Option<T> other)
→ Option<T>
-
Returns Some if exactly one of self,
other
is Some, otherwise returns None.
-
zip<U extends Object>(Option<U> other)
→ Option<(T, U)>
-
Zips self with another Option.
-
zipWith<U extends Object, R extends Object>(Option<U> other, R f(T, U))
→ Option<R>
-
Zips self and another Option with function f
Operators
-
operator [](_OptionEarlyReturnKey op)
→ T
-
Functions an "Early Return Operator" when given an "Early Return key" "$". See
Option.$
for more information.