Last active
February 16, 2017 07:11
-
-
Save mwrites/e78cc6bed3b13cb98edda83f59f801df to your computer and use it in GitHub Desktop.
Merge dictionaries
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
mutating func merge(with dictionary: Dictionary) { | |
dictionary.forEach { updateValue($1, forKey: $0) } | |
} | |
func merged(with dictionary: Dictionary) -> Dictionary { | |
var dict = self | |
dict.merge(with: dictionary) | |
return dict | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment