Dictionary... No Index Needed!
- Dictionary has keys and values, no index. How about array?
- Values are not in any particular order
- A key has to be unique.
- They are UNORDERED
- Keys in dictionary must be same type, but does not need to match type of value
- Keys and values are same type: var usStates = ["CA": "California", "TX": "Texas", "WA": "Washington"]
- Keys are doubles and values are strings: let fraction = [0.25: "1/4", 0.5: "1/2", 1: "1"]
- You are given optional when accessing in dictionary. Why? Remember nil or an item does not exist.
- You need to unwrap the value before you can use in dictionary.
- Use if-let to check if the value is a nil
- Add value to dictionary usStates["CA"] = nil