在下面的Scala代码中,使用foreach遍历元组列表,
val t1 = List((1,"A"), (2, "B"))
t1.foreach{
case(id, name) => println(id, name)
}
t1.foreach(x => println(x))
t1.foreach(case(id, name) => println(id, name))
error: illegal start of simple expression
t1.foreach(case(id, name) => println(id, name))
^
为什么{}有效,first()有效,而last()返回错误?