Extracts the value of a Maybe structure, if it exists (i.e.: is a Just
),
otherwise returns the provided default value.
forall a: (Maybe a).(a) => a
Extracts the value of a Maybe structure, if it exists (i.e.: is a Just
),
otherwise returns the provided default value.
const Maybe = require('folktale/maybe');
Maybe.Just(1).getOrElse(2); // ==> 1
Maybe.Nothing().getOrElse(2); // ==> 2
{
/*~*/
Nothing: function getOrElse(_default) {
return _default;
},
/*~*/
Just: function getOrElse(_default) {
return this.value;
}
}