optA
or optB
.
import { orElse, Option, some, none } from "./option.ts";
import { assertEquals } from "../deps.ts";
const nobody = orElse((): Option<string> => none());
const vikings = orElse((): Option<string> => some("vikings"));
assertEquals(vikings(some("barbarians")), some("barbarians"));
assertEquals(vikings(none()), some("vikings"));
assertEquals(nobody(none()), none());
Generated using TypeDoc
Returns the optional
optA
if it contains a value, otherwise callsoptB
and returns the result. The order of arguments is reversed because of that it is useful for partial applying.