Last active
June 6, 2016 11:32
-
-
Save darthpelo/4f3ea6208d274f996de4a4c6577aaf40 to your computer and use it in GitHub Desktop.
Currying in Swift, an example
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 appender(delimeter:String)->(String)->String { | |
| var buffer = "" | |
| return { | |
| buffer += $0 + delimeter | |
| return buffer | |
| } | |
| } | |
| let strings = ["a", "b", "c"] | |
| let append = appender(", ") | |
| var res = "" | |
| strings.forEach { res = append($0) } | |
| print(res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment