Extracts the value of a Result
structure, if it exists (i.e.: is an Ok
),
otherwise returns the provided default value.
This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.
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;
}
}