diff options
author | Tim Spence <timothywspence@gmail.com> | 2016-09-01 09:25:14 +0100 |
---|---|---|
committer | Tim Spence <timothywspence@gmail.com> | 2016-10-21 17:41:46 +0100 |
commit | 1583fbb6b94d0c9d30c1b1646ecebd1249e6389c (patch) | |
tree | 6be6a09a5121b7f57e50ff7ef7b42e1c72ada799 /src | |
parent | c492ac6022300ced8b56f523db5d17872e91b4b2 (diff) | |
download | scala-1583fbb6b94d0c9d30c1b1646ecebd1249e6389c.tar.gz scala-1583fbb6b94d0c9d30c1b1646ecebd1249e6389c.tar.bz2 scala-1583fbb6b94d0c9d30c1b1646ecebd1249e6389c.zip |
SI-9909: corrected stream example so it does not give forward reference
error
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/immutable/Stream.scala | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index db19df315f..3d4e32971c 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -23,7 +23,7 @@ import scala.language.implicitConversions * import scala.math.BigInt * object Main extends App { * - * val fibs: Stream[BigInt] = BigInt(0) #:: BigInt(1) #:: fibs.zip(fibs.tail).map { n => n._1 + n._2 } + * lazy val fibs: Stream[BigInt] = BigInt(0) #:: BigInt(1) #:: fibs.zip(fibs.tail).map { n => n._1 + n._2 } * * fibs take 5 foreach println * } @@ -46,7 +46,7 @@ import scala.language.implicitConversions * import scala.math.BigInt * object Main extends App { * - * val fibs: Stream[BigInt] = BigInt(0) #:: BigInt(1) #:: fibs.zip( + * lazy val fibs: Stream[BigInt] = BigInt(0) #:: BigInt(1) #:: fibs.zip( * fibs.tail).map(n => { * println("Adding %d and %d".format(n._1, n._2)) * n._1 + n._2 @@ -162,7 +162,7 @@ import scala.language.implicitConversions * // The first time we try to access the tail we're going to need more * // information which will require us to recurse, which will require us to * // recurse, which... - * val sov: Stream[Vector[Int]] = Vector(0) #:: sov.zip(sov.tail).map { n => n._1 ++ n._2 } + * lazy val sov: Stream[Vector[Int]] = Vector(0) #:: sov.zip(sov.tail).map { n => n._1 ++ n._2 } * }}} * * The definition of `fibs` above creates a larger number of objects than |