Logo

Programming-Idioms

History of Idiom 165 > diff from v18 to v19

Edit summary for version 19 by programming-idioms.org:
[D] List name items

Version 18

2018-02-09, 00:23:44

Version 19

2018-02-09, 00:24:00

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
int[42] list;
int x = list[$-1];
Code
int[42] items;
int x = items[$-1];
Comments bubble
The dollar operator represents the length of the array that's referred to inside the square brackets.
Comments bubble
The dollar operator represents the length of the array that's referred to inside the square brackets.
Doc URL
https://dlang.org/spec/arrays.html#array-length
Doc URL
https://dlang.org/spec/arrays.html#array-length