You can also use Swift functions to perform a merge:
public func +<K, V>(left: [K:V], right: [K:V]) -> [K:V] {
return left.merging(right) { $1 }
}
$ 1 will take the shared keys from the dictionary on the right, you can use $ 0 if you want to give priority to the left diction.
source
share