Last active
August 29, 2015 14:16
-
-
Save pselle/be4b40eb683045697307 to your computer and use it in GitHub Desktop.
Dictionary Map Function in Swift
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
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