Logo

Programming-Idioms

History of Idiom 13 > diff from v21 to v22

Edit summary for version 22 by :

Version 21

2015-09-13, 12:15:50

Version 22

2015-09-13, 12:18:13

Idiom #13 Iterate over map keys and values

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

Idiom #13 Iterate over map keys and values

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

Imports
import std.stdio;
Imports
import std.stdio;
Code
int[string] mymap = ["Hello":1 , "World":2];
foreach (k, v; mymap)
    writeln("Key: ", k, " Value: ", v);
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 built-in associative array