Last active
October 20, 2015 01:31
-
-
Save etcetc/e23123a0a0254a175a77 to your computer and use it in GitHub Desktop.
Merge two dictionaries in swift using reduce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let d1 = ["a":"foo","b":"bar"] | |
let d2 = ["c":"car","d":"door"] | |
let d3 = d1.reduce(d2) { (var d, p) in | |
d[p.0] = p.1 | |
return d | |
} | |
/* Result is ["b": "bar", "a": "foo", "d": "door", "c": "car"] */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment