Last active
September 15, 2015 12:02
-
-
Save darthpelo/b764043ada8e5eafc0de to your computer and use it in GitHub Desktop.
How to implement flatMap in Swift 1.2. An idea of Berik https://github.com/berikv.
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
| let list: [String?] = [nil, nil, "ciao", "hello", nil] | |
| list.reduce([String]()) { | |
| if let e = $1 { | |
| return $0 + [e] | |
| } else { | |
| return $0 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment