List.last
You're seeing just the function
last
, go back to List module for more information.
Specs
Returns the last element in list
or default
if list
is empty.
last/2
has been introduced in Elixir v1.12.0, while last/1
has been available since v1.0.0.
Examples
iex> List.last([])
nil
iex> List.last([], 1)
1
iex> List.last([1])
1
iex> List.last([1, 2, 3])
3