title: Scala nested for loop
body: <p>I'm a new Scala fellow and using processing library in scala ,I have 2 questions here:</p>
  
  <pre><code> val grid: Array[Cell] = Array()              
   val w = 60   
   val rows = height/w   
   val cols = width /w
  
   override def setup(): Unit = {  
     for(j &lt;- 0 until rows;   
         i &lt;- 0 until cols){   
     val cell = new Cell(i,j)   
     grid :+ cell   
     println(s"at row : $j, at col: $i") //it compiles only once (at row : 0, 
     }                                    //at col: 0 )                                          
  }
  override def draw(): Unit = {
    background(0)
    grid.foreach(cell =&gt; cell.display())//nothing happens
  } 
  </code></pre>
  
  <p>but if i replace the variables <code>rows</code> &amp; <code>cols</code> by <code>height/w</code> &amp; <code>width/w</code> in the nested loop as follows: </p>
  
  <pre><code>     for(j &lt;- 0 until height/w;   
           i &lt;- 0 until width/w){   
       val cell = new Cell(i,j)   
       grid :+ cell   
       println(s"at row : $j, at col: $i") //it compiles ordinary as nested 
          }                                 //for loop 
  </code></pre>
  
  <p>the second question is in the class <code>Cell</code> here:</p>
  
  <pre><code>   class Cell(i: Int,j:Int){
  
       def display(): Unit = {
         val x = this.i * w
         val y = this.j * w
  
         println("it works")//doesn't work
         //creating a square
         stroke(255)
         line(x,y,x+w,y)//top
         line(x+w,y,x+x,y+w)//right
         line(x,y+w,x+w,y+w)//bottom
         line(x,y,x,y+w)//left
  
     }
   }
  </code></pre>
  
  <p>the method display doesn't work when calling at function <code>draw()</code> but no errors show up</p>