Hi, I was experimenting with the lazy sequence.
But the code below doesn't work as expected.
Code
let array = [0, 1]
let lazySequence = array
.lazy
.map { value -> Int in
print("map1", value)
return value
}
.filter { value -> Bool in
print("filter", value)
return value % 2 == 0
}
.map { value -> Int in
print("map2", value)
return value
}
print(lazySequence[0])
My expect
map1 0
filter 0
map2 0
0
Result
map1 0
map2 0
0
Question
What is the point of ignoring print("filter", value)
?
Swift version
swift-driver version: 1.45.2 Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)
Target: arm64-apple-macosx12.0