The function provides an error used when opt
is a None
.
The new Result
.
import { okOrElse, some, none } from "./option.ts";
import { err, ok } from "./result.ts";
import { assertEquals } from "../deps.ts";
const orZero = okOrElse(() => 0);
assertEquals(orZero(some("foo")), ok("foo"));
assertEquals(orZero(none()), err(0));
Generated using TypeDoc
Transforms the optional value into
Result
with the errore()
.