swift3.0 拼接两个字典

func appendAnotherDic( left: inout Dictionary, right: Dictionary) {

for (k, v) in right {

left.updateValue(v, forKey: k)

}

}

var dic1 = ["first": "1", "second": "2"]

let dic2 = ["third": "3", "forth": "4"]

appendAnotherDic(left: &dic1, right: dic2)

print(dic1)

你可能感兴趣的:(swift3.0 拼接两个字典)