• Extracts the contained Some value or fn().

    Type Parameters

    • T

    Parameters

    • fn: (() => T)

      The function to provide a default value.

        • (): T
        • Returns T

    Returns ((opt) => T)

    The contained value or fn().

    Examples

    import { some, none, unwrapOrElse } from "./option.ts";
    import { assertEquals } from "../deps.ts";

    const unwrapOrCalc = unwrapOrElse(() => 6 ** 4);

    assertEquals(unwrapOrCalc(some(4)), 4);
    assertEquals(unwrapOrCalc(none()), 1296);
      • (opt): T
      • Parameters

        Returns T

Generated using TypeDoc