我是斯卡拉的新手.当我运行以下代码时:
object HelloWorld {
def main(args:Array[String]): Unit =
println("1" + (1 to 4))
println("2" + (1 to 4))
Thread.sleep(100)
for(x <- (1 to 4)) {
println(inc(x) + " " + inc_sq(x, 4))
}
def inc(i:Int): Int = i + 1
def inc_sq(i:Int, r:Int): Int =
(i+r) * (i+r)
}
Run Code Online (Sandbox Code Playgroud)
我得到了输出:
2Range(1, 2, 3, 4)
2 25
3 36
4 49
5 64
1Range(1, 2, 3, 4)
Run Code Online (Sandbox Code Playgroud)
为什么会出现这种疾病?我的意思是我认为实际输出的最后一行应该在第一行.
我在Eclipse中使用Mac和Scala.
scala ×1