Created
July 13, 2015 13:26
-
-
Save jk/48b90af92812a18d00a2 to your computer and use it in GitHub Desktop.
Merge dictionaries in place as described in http://ericasadun.com/2015/07/08/swift-merging-dictionaries/
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
extension Dictionary { | |
mutating func unionInPlace(dictionary: Dictionary<Key, Value>) { | |
for (key, value) in dictionary { | |
self[key] = value | |
} | |
} | |
mutating func unionInPlace<S: SequenceType where S.Generator.Element == (Key, Value)>(sequence: S) { | |
for (key, value) in sequence { | |
self[key] = value | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment