import { option } from "https://deno.land/x/fun@v2.0.0-alpha.12/mod.ts";
const { alt } = option;
Replace an first with second if first is None. This allows one to offer a a replacement or default.
Examples
Example 1
Example 1
import * as O from "./option.ts";
import { pipe } from "./fn.ts";
const result1 = pipe(O.some(1), O.alt(O.some(2))); // Some(1);
const result2 = pipe(O.some(1), O.alt(O.constNone())); // Some(1);
const result3 = pipe(O.none, O.alt(O.some(2))); // Some(2);
const result4 = pipe(O.none, O.alt(O.none)); // None