Created
December 22, 2014 06:21
-
-
Save akuraru/9abdf0411724daad740e to your computer and use it in GitHub Desktop.
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
extension Dictionary { | |
func map<K, V>(f: (Key, Value) -> (K, V)) -> [K: V] { | |
var r = Dictionary<K, V>(minimumCapacity: self.count) | |
for key in self.keys { | |
let (k, d) = f(key, self[key]!) | |
r[k] = d | |
} | |
return r | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment