Scala Language Basic For Loop


Example

for (x <- 1 to 10)
  println("Iteration number " + x)

This demonstrates iterating a variable, x, from 1 to 10 and doing something with that value. The return type of this for comprehension is Unit.