The last collection type we will look at is the Dictionary, which is a familiar construct in programming languages, where it is sometimes referred to as a hash table. A dictionary holds a collection of pairings between a key and a value. The key can be any element that conforms to the Hashable protocol (just like elements in a set), and the value can be any type. The contents of a Dictionary are not stored in order, unlike an array; instead, the key is used both when storing a value and as a lookup when retrieving a value.
Storing key-value pairs with Dictionaries
Getting ready
In this recipe, we will use a Dictionary to store details of people at a place of work. We need to store and retrieve a person's information based...