Safely get the value out of a Maybe by returning the wrapped value
if it is Just, or by applying orElseFn if it is
Nothing.
This is useful when you need to generate a value (e.g. by using current
values in the environment – whether preloaded or by local closure) instead of
having a single default value available (as in unwrapOr).
importMaybefrom'true-myth/maybe';
// You can imagine that someOtherValue might be dynamic. constsomeOtherValue = 99; consthandleNothing = () =>someOtherValue;
Safely get the value out of a
Maybe
by returning the wrapped value if it isJust
, or by applyingorElseFn
if it isNothing
.This is useful when you need to generate a value (e.g. by using current values in the environment – whether preloaded or by local closure) instead of having a single default value available (as in
unwrapOr
).