var airports = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]
var airports2 = ["YYZ2": "Toronto Pearson2", "DUB2": "Dublin2"]
var airports3 = airports + airports2
extension Dictionary {
mutating func merge(other:Dictionary) {
for (key,value) in other {
self.updateValue(value, forKey:key)
}
}
}
let airports = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]
let airports2 = ["YYZ2": "Toronto Pearson2", "DUB2": "Dublin2"]
var airports3 = [String : String]()
airports3.merge(airports)
airports3.merge(airports2)
print(airports3)
// ["YYZ": "Toronto Pearson", "YYZ2": "Toronto Pearson2", "DUB": "Dublin", "DUB2": "Dublin2"]