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