diff --git a/hands-on_dlang.md b/hands-on_dlang.md index 7600220..9bd36f3 100644 --- a/hands-on_dlang.md +++ b/hands-on_dlang.md @@ -56,8 +56,8 @@ brew cask install visual-studio-code * Open the Extension view in the sidebar: |Operating system|Shortcut | |----------------|---------| - |OS X |⌘ + ⇧ + X| - |Windows |⌃ + ⇧ + X| + |OS X|⌘ + ⇧ + X| + |Windows|⌃ + ⇧ + X| * Install the extension “D Programming Language (code-d)” (requires that git is installed). * Restart Visual Studio Code. @@ -721,3 +721,17 @@ Slices are the most prominent example of `RandomAccessRange`s in The D standard library provides a huge arsenal of lazy range algorithm functions. Most of them can be found in in the `std.range` and `std.algorithm` packages. + +### Associative arrays + +D has builtin hashmaps, which are called _associative arrays_: + +```D +int[string] map; // keys of type string, values of type int +map["key1"] = 10; // insertion or modification, if the key already exists +if ("key1" in map) { // checking if a key is in an associative array + writeln("key1 is in map"); +} +assert(map.length == 1); // associative arrays provide a .length property +map.remove("key1"); // remove a key from an associative array +```