Logo

Programming-Idioms

History of Idiom 165 > diff from v5 to v6

Edit summary for version 6 by programming-idioms.org:
[Ruby] 2 ways -> new impl 2136

Version 5

2017-10-23, 19:15:38

Version 6

2017-10-23, 19:16:20

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 = items.last
Code
x = items.last
Comments bubble
x = items[-1] is another way.