last

Returns the last value of an array. Consumes the array before returning. Throws an Error if the array is empty. Does not terminate on infinite arrays.

Type

type last = <E>(s: Array<E>) => E

Example

import {last} from 'fnxt/array';

const array = [2, 3, 4];
last(array) // -> 4

See Also

|  head  |              tail              |
|---[0]-----[1]-----[2]-----[3]-----[4]---|
|              init              |  last  |