Logo

Programming-Idioms

History of Idiom 13 > diff from v8 to v9

Edit summary for version 9 by :

Version 8

2015-08-20, 14:29:36

Version 9

2015-08-20, 16:44:29

Idiom #13 Iterate over map keys and values

Print each key k i with its value x from an associative array mymap

Idiom #13 Iterate over map keys and values

Print each key k i with its value x from an associative array mymap

Imports
import std.stdio;
Imports
import std.stdio;
Code
int[string] aa;
foreach (string k; aa.byKey)
    writeln("Key: ", k, " Value: ", aa[k]);
Code
int[string] mymap = ["Hello":1 , "World":2];
foreach (k, v; mymap)
    writeln("Key: ", k, " Value: ", v);
Comments bubble
D has build-in associative array
Comments bubble
D has build-in associative array