Logo

Programming-Idioms

History of Idiom 165 > diff from v27 to v28

Edit summary for version 28 by Frederick John:
New Elixir implementation by user [Frederick John]

Version 27

2019-01-06, 03:37:24

Version 28

2019-01-06, 08:00:51

Idiom #165 Last element of list

Assign to variable x the last element of list items.

Idiom #165 Last element of list

Assign to variable x the last element of list items.

Code
x = List.last(items)
Comments bubble
The last() function of the List module returns the last item in the list or nil.
Doc URL
https://hexdocs.pm/elixir/List.html#last/1