Skip to content

Instantly share code, notes, and snippets.

@akuraru
Created December 22, 2014 06:21
Show Gist options
  • Save akuraru/9abdf0411724daad740e to your computer and use it in GitHub Desktop.
Save akuraru/9abdf0411724daad740e to your computer and use it in GitHub Desktop.
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