okOrElse<E> method
Transforms an Option into a Result, mapping Some to an Ok of the contained value and
None to Err of the result of calculateError
.
Examples
// prints "Ok(2)"
print(const Some(2).okOrElse(() => 'none'));
// prints "Err(none)"
print(const None<int>().okOrElse(() => 'none'));
Implementation
@override
@useResult
Ok<T, E> okOrElse<E>(E Function() calculateError) => Ok(value);