val xs = Iterator
.from(1)
.dropWhile(_ % 2 != 0)
.takeWhile(_ < 10)
.toList
val ys = Iterator
.from(1)
.filter(_ % 2 == 0)
.takeWhile(_ < 10)
.toList
println(xs)
println(ys)
输出:
List(2, 3, 4, 5, 6, 7, 8, 9)
List(2, 4, 6, 8)
为什么?我期望两者的输出是相同的。
https://stackoverflow.com/questions/51583361
复制相似问题