0

In Scala 2.9.1, this does not compile, failing with not found: 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))
}

However, this does:

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))
}  

The only difference is the commented line. If this isn't a bug, why is this the intended behavior?

Mark
  • 5,286
  • 5
  • 42
  • 73

0 Answers0