Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-9909

Stream fibs example breaks: forward reference extends over definition

    Details

      Description

      The example given for Streams fails to compile with this error:

      Error:(597, 60) forward reference extends over definition of value fibs
          val fibs: Stream[BigInt] = BigInt(0) #:: BigInt(1) #:: fibs.zip(fibs.tail).map { n => n._1 + n._2 }
      

      https://github.com/scala/scala/blob/2.12.x/src/library/scala/collection/immutable/Stream.scala#L23-L38

      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 }
       *
       *    fibs take 5 foreach println
       *  }
       *
       *  // prints
       *  //
       *  // 0
       *  // 1
       *  // 1
       *  // 2
       *  // 3
      

        Attachments

          Activity

            People

            • Assignee:
              timspence Tim Spence
              Reporter:
              xevix Alejandro Wainzinger
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: