Skip to content

Instantly share code, notes, and snippets.

@mwrites
Last active February 16, 2017 07:11
Show Gist options
  • Save mwrites/e78cc6bed3b13cb98edda83f59f801df to your computer and use it in GitHub Desktop.
Save mwrites/e78cc6bed3b13cb98edda83f59f801df to your computer and use it in GitHub Desktop.
Merge dictionaries
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