title: only once in while loop with scala
body: <p>I'm beginning with Scala. I have a program which have a method with a while loop which run until the program is not ended.</p>
  
  <p>But for my test, I need to execute this method only once (or twice). In java, I would have used a mutable variable that I would have decremented in order to stop my treatment.</p>
  
  <p>Maybe a condition inside my while loop that I override for my test.</p>
  
  <pre><code>def receive = {
      val iterator = stream.iterator()
      while (iterator.hasNext &amp;&amp; my_condition()) {
          something_to_do
      }
  }
  </code></pre>
  
  <p>I know it's a stupid question, but could you please advice me ?</p>