Function: orElse()
Call Signature
orElse<
T
,R
>(elseFn
,maybe
):Maybe
<ValueFor
<R
>>
Like or
, but using a function to construct the alternative Maybe
.
Sometimes you need to perform an operation using other data in the environment to construct the fallback value. In these situations, you can pass a function (which may be a closure) as the elseFn
to generate the fallback Maybe<T>
.
Useful for transforming empty scenarios based on values in context.
Type Parameters
T
T
The type of the wrapped value.
R
R
extends AnyMaybe
Parameters
elseFn
() => R
The function to apply if maybe
is Nothing
maybe
Maybe
<T
>
The maybe
to use if it is Just
.
Returns
Maybe
<ValueFor
<R
>>
The maybe
if it is Just
, or the Maybe
returned by elseFn
if the maybe
is Nothing
.
Call Signature
orElse<
T
,R
>(elseFn
): (maybe
) =>Maybe
<ValueFor
<R
>>
Like or
, but using a function to construct the alternative Maybe
.
Sometimes you need to perform an operation using other data in the environment to construct the fallback value. In these situations, you can pass a function (which may be a closure) as the elseFn
to generate the fallback Maybe<T>
.
Useful for transforming empty scenarios based on values in context.
Type Parameters
T
T
The type of the wrapped value.
R
R
extends AnyMaybe
Parameters
elseFn
() => R
The function to apply if maybe
is Nothing
Returns
The maybe
if it is Just
, or the Maybe
returned by elseFn
if the maybe
is Nothing
.
(
maybe
):Maybe
<ValueFor
<R
>>
Parameters
maybe
Maybe
<T
>
Returns
Maybe
<ValueFor
<R
>>