14.13 Adding and Removing Dictionary Entries
Items may be added to a dictionary using the following key subscripting syntax:
dictionaryVariable[key] = value
For example, to add a new key-value pair entry to the books dictionary:
bookDict["300-898871"] = "The Overlook"
Removal of a key-value pair from a dictionary may be achieved either by assigning a nil value to the entry, or via a call to the removeValueForKey method of the dictionary instance. Both code lines below achieve the same result of removing the specified entry from the books dictionary:
bookDict["300-898871"] = nil
bookDict.removeValue(forKey: "300-898871")