Day 5 : Dictionaries in Swift

  1. Dictionary: This is another way of storing collection of data.

//Dictionary

var dict: [String:String] = [“name”:”Amrit”]

2. Dictionary do not keep the order of the items.

3. We can access items in Dictionary, by subscripting.

//Accessing Items in Dictionary

dict[“name”]

4. If Dictionary is immutable then we can change or add more value pairs, however we can add, update key-value pairs in dictionary by:

//Inserting values

dict[“age”] = [“20”]

dict[“age”] = [“20.5”]

//Do not insert Int in String

5. We can also update or remove key value pairs

//updating key value pairs

dict.updateValue(“Amrit Pandey” forKey: “name”)

//removing key value pairs

dict.removeValue(forKey: “age”)

SHORT CODE-SUMMARY OF WHAT I LEARNED TODAY:

https://repl.it/HugX/1 (last modified: 12/05/2017)[please update if u change anything!]

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.