0

在 Scala 2.9.1 中,这不会编译,失败并没有找到: value 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))
}  

唯一的区别是注释行。如果这不是错误,为什么这是预期的行为?

4

0 回答 0