Option
Index
Accessor
getOrElse
Type parameters
- Value
- DefaultValue
getOrThrow
Returns the value if
Some
, throw an error ifNone
⚠ Impure function that may throw an error, its use is generally discouraged.
Type parameters
- Value
Constructor
Some
An identity function that validates passed value
Type parameters
- Value
from
Try to coerce value to
Option
Type parameters
- Value
Type
isNone
Return
true
ifanyValue
isnull
orundefined
isSome
Return
true
ifanyValue
is neithernull
norundefined
Type parameters
- Value
Other
None
Alias for undefined
Some
Non null
and non undefined
value
Type parameters
- Value
None
andThen
Returns
Option.None
if the option isOption.None
, otherwise callsfn
with the value and returns the result. Some languages call this operationflatMap
orchain
.Type parameters
- ValueFrom
- ValueTo
map
Maps a
Option<Value>
toOption<U>
by applying a function to a containedSome
value, leaving aNone
value untouched. This function can be used to compose the results of two functions.Type parameters
- ValueFrom
- ValueTo
match
Return
matchers.Some(value)
ifoption
isSome
, otherwisematchers.None()
Type parameters
- Value
- Return
orElse
Returns the option if it contains a value, otherwise calls
fn
and returns the result.Type parameters
- ValueFrom
Returns the
value
ifSome
,getDefaultValue()
ifNone
.