Dictionary initialization
var groupsDict = [String:String]() var animalGroupsDict = ["whales":"pod", "geese":"flock", "lions":"pride"] var averageLifeSpanDic = [String:Range<Int>]() var lifeSpanDic = ["African Grey Parrot":50...70, "Tiger Salamander":12...15, "Bottlemose Dolphin":20...30]
Dictionary operation
animalGroupsDict["crows"] = "murder"
animalGroupsDict["monkey"] = "troop"
animalGroupDict.count
println(animalGroupDict)
animalGroupDict["crows"] = nil
animalGroupDict
animalGroupsDict["monkeys"] = "barrel"
var group = animalGroupsDict.updateValue["gaggle", forKey: "geese"]
group.dynamicType
animalGroupsDict.updateValue("crash", forKey: "rhioceros")
println(animalGroupsDict)
if let groupOfWhales = animalGroupsDict["whales"]{
println("We saw a \(groupOfWhales) of whales from the boat.")
} else {
println("No value found for that key.")
}