我正在尝试学习 scala,这里我使用基本的 for 循环,但是在编译时出现错误。
object App {
def main(args: Array[String]) {
for (i <- 1 to 10; i % 2 == 0)
Console.println("Counting " + i)
}
}
编译时出错:
fortest.scala:5: error: '<-' expected but ')' found.
for (i <- 1 to 10; i % 2 == 0)
^
fortest.scala:7: error: illegal start of simple expression
}
^
two errors found
我正在使用 scala 版本 2.9.1
任何想法是什么问题........?