The main (but not only) reason why they are different is boxing.
In code:
for (i <- 0 until n) println(s"for loop with $i")
You pass an anonymous function println(s"for loop with $i")to understanding for (i <- 0 until n). This is equivalent to:
(0 until n) foreach (i =>
println(s"for loop with $i")
}
-, , i int, Integer. Java Fixnum, , , , Smalltalk ( , , !)
-optimize , .
scalaxy/loops, :)