Transforms the optional value into Result with the error e().
Result
e()
The function provides an error used when opt is a None.
opt
None
The new Result.
const orZero = okOrElse(() => 0);expect(orZero(some("foo"))).toStrictEqual(ok("foo"));expect(orZero(none())).toStrictEqual(err(0)); Copy
const orZero = okOrElse(() => 0);expect(orZero(some("foo"))).toStrictEqual(ok("foo"));expect(orZero(none())).toStrictEqual(err(0));
Transforms the optional value into
Resultwith the errore().