Function last

  • Safely get the last item from a list, returning Just the last item if the array has at least one item in it, or Nothing if it is empty.

    let empty = [];
    Maybe.last(empty); // => Nothing

    let full = [1, 2, 3];
    Maybe.last(full); // => Just(3)

    Type Parameters

    • T

    Parameters

    • array: AnyArray<undefined | null | T>

      The array to get the first item from.

    Returns Maybe<T>