Last active
August 29, 2015 14:18
-
-
Save joanmolinas/5a9fb86d12ba04e2d1e4 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
func addPrefix(c : Character) -> (String) -> String { | |
return { | |
(currentString : String) -> String in | |
let result = String(c) + currentString | |
return result | |
} | |
} | |
//OR | |
func insertPrefix(s : String, c : Character) -> String { | |
return String(c) + s | |
} | |
func addPrefix(c : Character) -> (String) -> String { | |
return { | |
(currentString : String) -> String in | |
return insertPrefix(currentString, c) | |
} | |
} | |
var ar = ["aaa", "bbb", "ccc", "ddd"] | |
ar.map(addPrefix("z")) //OUTPUT -> ["zaaa", "zbbb", "zccc", "zddd"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment