为什么流中的最后一个计算项没有出现在 REPL 中?
why the last computed item in a stream doesn't appear in REPL?
最近,我 运行 在 REPL 中对流进行了一些测试,但奇怪的是,流中的最后一个计算项没有显示。我的意思的例子:
val s = Stream.from(1)
// scala.collection.immutable.Stream[Int] = Stream(1, ?)
s(5)
// Int = 6
s
// scala.collection.immutable.Stream[Int] = Stream(1, 2, 3, 4, 5, ?)
也许我遗漏了什么,但我希望 s
包含 6(即 s(5)
)。
谁能解释一下?
[scala 版本 2.11.6(OpenJDK 64 位服务器虚拟机,Java 1.7.0_91)]
这是 scala 2.11.6 中的错误,已在 2.11.7 中修复
有关详细信息,请参阅 https://issues.scala-lang.org/browse/SI-9219
最近,我 运行 在 REPL 中对流进行了一些测试,但奇怪的是,流中的最后一个计算项没有显示。我的意思的例子:
val s = Stream.from(1)
// scala.collection.immutable.Stream[Int] = Stream(1, ?)
s(5)
// Int = 6
s
// scala.collection.immutable.Stream[Int] = Stream(1, 2, 3, 4, 5, ?)
也许我遗漏了什么,但我希望 s
包含 6(即 s(5)
)。
谁能解释一下?
[scala 版本 2.11.6(OpenJDK 64 位服务器虚拟机,Java 1.7.0_91)]
这是 scala 2.11.6 中的错误,已在 2.11.7 中修复
有关详细信息,请参阅 https://issues.scala-lang.org/browse/SI-9219