基本的迴圈

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

這演示瞭如何將一個變數 x 從 1 迭代到 10 並使用該值進行處理。這個 for 理解的返回型別是 Unit。