What changes in a class when you declare a constructor value with val
? I noticed that it behaves differently below:
scala> :paste
// Entering paste mode (ctrl-D to finish)
class Foo(value: String) extends Bar
class Bar { this: Foo =>
def go = println(value)
}
// Exiting paste mode, now interpreting.
<console>:9: error: not found: value value
def go = println(value)
^
scala> :paste
// Entering paste mode (ctrl-D to finish)
class Foo(val value: String) extends Bar
class Bar { this: Foo =>
def go = println(value)
}
// Exiting paste mode, now interpreting.
defined class Foo
defined class Bar