Add to a Dictionary in D

github logo ・1 min read

Python (14 Part Series)

1) Boolean in D 2) Comments in D 3 ... 12 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 10) Check Dictionary has key in D 11) Filter a Dictionary in D 12) Split, Apply, Merge in D 13) Map Reduce in D 14) Skip the first line of a file 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 May 15 '19

What are your five most used terminal commands?

community post to share our most used terminal commands.

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