We use the subscript syntax to retrieve the value for a particular key. If the dictionary does not contain the key we are looking for, the dictionary will return nil; therefore, the variable returned from this lookup is an optional variable. The following example shows how to retrieve a value from a dictionary using its key in the subscript syntax:
let countries = ["US":"United States", "IN":"India","UK":"UnitedKingdom"] var name = countries["US"]
In the preceding code, the variable name will contain this string: United States.