Option
Index
Accessor
getOrElse
getOrThrow
Returns the value if
Some, throw an error ifNone⚠ Impure function that may throw an error, its use is generally discouraged.
Constructor
from
Try to coerce value to
Option
Some
An identity function that validates passed value
Type
isNone
Return
trueifanyValueisnullorundefined
isSome
Return
trueifanyValueis neithernullnorundefined
Other
None
Alias for undefined
Some
Non null and non undefined value
Type parameters
- Value
None
andThen
Returns
Option.Noneif the option isOption.None, otherwise callsfnwith the value and returns the result. Some languages call this operationflatMaporchain.
map
Maps a
Option<Value>toOption<U>by applying a function to a containedSomevalue, leaving aNonevalue untouched. This function can be used to compose the results of two functions.
orElse
Returns the option if it contains a value, otherwise calls
fnand returns the result.
Returns the
valueifSome,getDefaultValue()ifNone.