Created
June 1, 2019 23:37
-
-
Save RinniSwift/ff301603b27294778efb7d720fffaec7 to your computer and use it in GitHub Desktop.
This file contains 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
var dict = ["blue": 2, "grey": 1, "red": 2] | |
var newDict = ["pink": 3, "red": 5] | |
dict.merge(newDict) { (current, _) in current } // ["blue": 2, "grey": 1, "red": 2, "pink": 3] | |
dict.merge(newDict) { (_, new) in new } // ["blue": 2, "grey": 1, "red": 5, "pink": 3] | |
let mergedDict = dict.merging(newDict) { (current, _) in current} // ["blue": 2, "grey": 1, "red": 5, "pink": 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment