title: Forward reference error in a for loop Scala
body: <p>This is a code that is written in Scala :</p>
  
  <pre><code>for (i &lt;- 0 until 10) {
    if (i &gt; 0) {
      val new = theta(i * 5)
    }
    // using variable new
  
    val theta = DenseVector.zeros[Int]((i + 1) * 10)
    // doing operations on theta
  }
  </code></pre>
  
  <p>every iteration has own variables and order of variables can't change because between them doing some operations.</p>
  
  <p>when i running this code it shows this error:</p>
  
  <pre><code>Wrong forward reference
  </code></pre>
  
  <p>how can i resolve this problem?</p>