Logo

Programming-Idioms

History of Idiom 7 > diff from v14 to v15

Edit summary for version 15 by :

Version 14

2015-08-20, 07:08:37

Version 15

2015-08-20, 15:31:42

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Code
foreach(i, x; items)
{
   writefln("%s: %s", i, x);
}
Comments bubble
use 'ref' on the item variable 'x' to access by reference