I am learning scala, and I am trying to do the equivalent of this C++ code in scala, but I get a compile error. Here's the c++ code:
for(reels[0] = 0; reels[0] < 10; reels[0]++)
doStuff();
I have tried to implement this loop in scala like:
var reels: Array[Int] = new Array[Int](5)
for(reels(0) <- 0 until 10)
doStuff
This results in a compile error on the for loop:
variable reels is not a case class, nor does it have an unapply/unapplySeq member
If I replace reels(0)
with a regular Int
variable, it works fine. Why is that, and more importantly, how would I iterate the array element. More specifically, what I want to do is nest 5 loops, and have each loop iterate exactly one of the reels one at a time. I do not want to define 5 separate variables to get around the problem.
Thanks in advance.