The content of maybe
if it is a Just
, otherwise
defaultValue
.
Safely get the value out of a Maybe
.
Returns the content of a Just
or defaultValue
if
Nothing
. This is the recommended way to get a value out of a
Maybe
most of the time.
import Maybe from 'true-myth/maybe';
const notAString = Maybe.nothing<string>();
const isAString = Maybe.just('look ma! some characters!');
console.log(Maybe.unwrapOr('<empty>', notAString)); // "<empty>"
console.log(Maybe.unwrapOr('<empty>', isAString)); // "look ma! some characters!"
The value to return if maybe
is a Nothing
.
The content of maybe
if it is a Just
, otherwise
defaultValue
.
Safely get the value out of a
Maybe
.Returns the content of a
Just
ordefaultValue
ifNothing
. This is the recommended way to get a value out of aMaybe
most of the time.