Skip to main content

last

Callable


  • Take the Traversable and return the last element.

    The function evaluates the Traversable and converts it into an array.

    Example

    last([1, 2, 3])
    // => 3

    function* foobar() {
    yield 'foo'
    yield 'bar'
    }
    last(foobar())
    // => "bar"

    last([])
    // => Nothing

    Type parameters

    • T

      The element type.

    Parameters

    Returns Maybe<T>

    The last element if it exists, otherwise Nothing.