I found the code snippet from this thread: https://stackoverflow.com/a/24052094/2754218 and tested it in a Playground.
func +=<K, V> (inout left: [K: V], right: [K: V]){
for (k, v) in right {
left[k] = v
}
}
var test = ["1": "a"] += ["2": "b"]
The code causes: Binary operator '+=' cannot be applied to two [String : String] operands.
Any suggestion?
SOLUTION:
Thanks to Eric's I create a function with the operator "+":
func +<K, V> (left: [K: V], right: [K: V]) -> [K: V] {
var newDic = left
for (k, v) in right {
newDic[k] = v
}
return newDic
}
var toto = ["1": "a"] + ["2": "b"]