• Converts Option into a list.

    Type Parameters

    • T

    Parameters

    • opt: Option<T>

      The source optional.

    Returns List<T>

    The list of zero or one elements.

    Examples

    import { empty, fromOption } from "./list.ts";
    import * as Option from "./option.ts";
    import { assertEquals } from "../deps.ts";

    const listOf2 = fromOption(Option.some(2));
    assertEquals(listOf2.current(), Option.some(2));
    assertEquals(listOf2.rest(), empty());

    const listOfNone = fromOption(Option.none());
    assertEquals(listOfNone.current(), Option.none());
    assertEquals(listOfNone.rest(), empty());

Generated using TypeDoc