Skip to content

Instantly share code, notes, and snippets.

@Julioacarrettoni
Created December 22, 2015 21:35
Show Gist options
  • Save Julioacarrettoni/8a68609ee8246890443d to your computer and use it in GitHub Desktop.
Save Julioacarrettoni/8a68609ee8246890443d to your computer and use it in GitHub Desktop.
Possible bug on Swift 2?
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]
}.first
array.lazy.flatMap { (value) -> [Int] in
print("value: \(value)")
return [value]
}.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