Last active
December 22, 2015 20:57
-
-
Save Julioacarrettoni/fd31c5b35d3eaf5154e4 to your computer and use it in GitHub Desktop.
Playing with lazy collections and maps and flats and stuff… (and getting really really confused)
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 array = [1, 2, 3, 4, 5, 6] | |
array.map { (value) -> [Int] in | |
print(value) | |
return [value] | |
} | |
array.lazy.map { (value) -> [Int] in | |
print("value: \(value)") | |
return [value+1] | |
}.first | |
array.lazy.flatMap { (value) -> [Int]? in | |
print("value: \(value)") | |
return value > 3 ? [value] : nil | |
}.first |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment