This page is no longer maintained — Please continue to the home page at www.scala-lang.org

How do I write a loop?

There are two ways for simple integer loops:

for (i <- 1 to 1000000) { ... }

or

var i = 1;  while (i <= 1000000){ ...; i += 1 }

Both are fine, but in the current implementation the second one should be more efficient.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland