import { unwrapOrElse } from "https://deno.land/x/optio@1.0.0/operators/extract.ts";
Returns the contained Some
value, otherwise computes it from a closure.
Examples
Example 1
Example 1
import { None, Some } from "https://deno.land/x/optio/spec.ts";
import { unwrapOrElse } from "https://deno.land/x/optio/operators/extract.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
assertEquals(unwrapOrElse(Some(0), () => 2 ** 3), 0);
assertEquals(unwrapOrElse(None, () => 2 ** 3), 8);