Skip to content

Instantly share code, notes, and snippets.

@pselle
Last active August 29, 2015 14:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pselle/be4b40eb683045697307 to your computer and use it in GitHub Desktop.
Dictionary Map Function in Swift
func mapDict<S, T, U>(myDict:[S:T], f: T -> U) -> [S:U] {
var newDict = [S: U]()
for (key, val) in myDict {
newDict[key] = f(val)
}
return newDict
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment