在Scala 2.9.1中,这不能编译,失败,未找到:值b :
case class CaseClass(field: String)
object SomeObject {
//val kludge = field
def x(input: (CaseClass, String) => CaseClass): Unit = ()
val field = x((a, b) => a.copy(field = b))
}
但是,这样做:
case class CaseClass(field: String)
object SomeObject {
val kludge = field
def x(input: (CaseClass, String) => CaseClass): Unit = ()
val field = x((a, b) => a.copy(field = b))
}
唯一的区别是注释行。如果这不是一个错误,为什么这是预期的行为?