Contact: aviboots(AT)netvision.net.il
39,845 questions
51,766 answers
573 users
import Foundation let map1 = ["a": 1, "b": 2] let map2 = ["b": 999, "c": 4, "d": 5] let combined = map1.merging(map2) { (_, new) in new } print(combined) /* run: ["c": 4, "b": 999, "a": 1, "d": 5] */
import Foundation let map1 = ["a": 1, "b": 2] let map2 = ["b": 999, "c": 4, "d": 5] let combined = map1.merging(map2) { old, new in old + new } print(combined) /* run: ["d": 5, "c": 4, "a": 1, "b": 1001] */