title: Scala Iterator next method caching result?
body: <p>I'm having problems with this code:</p>
  
  <pre><code>case class MyIterator(myVal: Int) extends Iterator[MyIterator] {
      override def hasNext:Boolean = true
      override def next(): MyIterator = MyIterator(myVal+1)
      override def toString:String = s"MyIterator : $myVal"
  }
  
  object Main extends App {
      val mi = new MyIterator(0)
      mi.take(5).foreach(println(_))
  }
  </code></pre>
  
  <p>What I'd like to see is:</p>
  
  <pre><code>MyIterator : 0
  MyIterator : 1
  MyIterator : 2
  MyIterator : 3
  MyIterator : 4
  </code></pre>
  
  <p>but instead I'm getting:</p>
  
  <pre><code>MyIterator : 1
  MyIterator : 1
  MyIterator : 1
  MyIterator : 1
  MyIterator : 1
  </code></pre>
  
  <p>and I really can't see why. Does anybody know what's going on?</p>