Description Usage Arguments Format Details Value See Also Examples
For when you truly need to unpack the original value before you can continue operations. Try to avoid using this. Preferably, it should only be used at the end of a chain of function calls - all preceding function calls should be lifted to operate on Maybe types.
1 | maybe_default(m, default)
|
m |
A Maybe type object (Just or Nothing) |
default |
A value to return if m is Nothing. Cannot be null. |
maybe_default :: Maybe a -> a -> a
N.B. Don't access the maybe element of the underlying list directly (i.e, never
write my_value$value
), always access the value using maybe_default().
The contained value or, if m is Nothing, the default value
Other Maybe functions: as_maybe
,
is_nothing
, maybe_apply
,
maybe_bind
, maybe_map_2
,
maybe_map_3
, maybe_map_4
,
maybe_map_5
, maybe_map
,
maybe_then
, maybes_collapse
,
maybes_partition
1 2 | maybe_default(Just(42), 100) # 42
maybe_default(Nothing(), 100) # 100
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.