requireLast()function

requireLast(items: PossibleArray<T>, caller: AnyCaller = requireLast): T
ParamType
itemsPossibleArray<T>
The array or iterable to read from. required
callerAnyCaller
Function to attribute a thrown error to (defaults to requireLast itself). Defaults to requireLast
Return
T
The last item.
Throws
RequiredError
If items is empty.

Get the last item from an array or iterable.

Examples

requireLast([1, 2, 3]) // 3