We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should we change like this?
--- a/src/library/scala/collection/immutable/LazyList.scala +++ b/src/library/scala/collection/immutable/LazyList.scala @@ -564,17 +564,17 @@ object LazyList extends LazyListFactory[LazyList] { protected def headDefined: Boolean = false } - final class Cons[A](hd: => A, tl: => LazyList[A]) extends LazyList[A] { - private[this] var hdEvaluated: Boolean = false - private[this] var tlEvaluated: Boolean = false + final class Cons[A](private var hd: () => A, private var tl: () => LazyList[A]) extends LazyList[A] { override def isEmpty: Boolean = false override lazy val head: A = { - hdEvaluated = true - hd + val result = hd() + hd = null + result } override lazy val tail: LazyList[A] = { - tlEvaluated = true - tl + val result = tl() + tl = null + result } def force: this.type = { // Use standard 2x 1x iterator trick for cycle detection ("those" is slow one) @@ -596,8 +596,8 @@ object LazyList extends LazyListFactory[LazyList] { this } - protected def tailDefined: Boolean = tlEvaluated - protected def headDefined: Boolean = hdEvaluated + protected def tailDefined: Boolean = tl == null + protected def headDefined: Boolean = hd == null }
The text was updated successfully, but these errors were encountered:
scala/scala@5a985e9#diff-04841eeda02f00638b4cda505dbeafbeR559
Sorry, something went wrong.
No branches or pull requests
Should we change like this?
The text was updated successfully, but these errors were encountered: