Add to a Dictionary in D

github logo ใƒป1 min read

Python (9 Part Series)

1) Boolean in D 2) Comments in D 3 ... 7 3) Raise Exceptions in D 4) Add to a List in D 5) Count of a List in D 6) String Contained in a String in D 7) Where did my string go in D 8) Case Insensitive in D 9) Add to a Dictionary in D

Dictionary, hash table, associative array, map it has many names. The main challenge with dictionary adds is more around nested associative arrays, are you going to be annoyed if I select a different name every time?

int[string] dict;
dict["Key"] = 55;

There is a Dictionary literal in D.

auto data = ["key" : 55]

but this is not good for adding data as it will replace the variable with a new object. However if you're nesting and the inner dictionary might be null it can be good to use for starting a dictionary.

string[int][string] data;
data["hello"] = [95: "value"];
twitter logo DISCUSS
Classic DEV Post from Sep 17 '18

How I broke on my First PR

A tale of two face-palms

Jesse Phillips profile image
Senior Quality Assurance (SDET) starting to establish a larger presence in communities.