Logo

Programming-Idioms

History of Idiom 165 > diff from v23 to v24

Edit summary for version 24 by dmaestro:
New Perl implementation by user [dmaestro]

Version 23

2018-04-18, 13:11:11

Version 24

2018-08-18, 22:11:54

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
my $x = $items[-1];
Comments bubble
$items[] looks up a single element from list @items.
Negative indices count from the end of the list.