import { orElse } from "https://deno.land/x/optio@1.0.0/mod.ts";
Returns the option
if it Some
, otherwise calls fn
and returns the result.
Examples
Example 1
Example 1
import { orElse } from "https://deno.land/x/optio/operators/logical.ts";
import { None, Some } from "https://deno.land/x/optio/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
assertEquals(orElse(Some(0), () => Some(1)), Some(0));
assertEquals(orElse(None, () => Some(1)), Some(1));