Associative array of strings
Part of ForeachCategory
Description
Foreach with an associative array of dynamic strings (uses alias, too)
Example
import std.stdio; void main() { /* create an associative array called "map" */ char[][char[]] map; map["abc"] = "apple"; map["def"] = "bee"; map["xyz"] = "cat"; /* The foreach is used to determine the contents of the associative array. Note that the types of 'key' and 'value' are inferred. */ writefln("Iterating over map..."); foreach (key, value; map) writefln("\t%s => %s", key, value); }
Source
This example was inspired on an example posted by csauls and from comments by larsivi.