difference between def/val assignment
Hi all,
running the following code yields
null
null
null
new value
class Data {
var value: String = _
}
object DataTest {
def main(args: Array[String]) {
def a = new Data
val b = new Data
println(a.value)
println(b.value)
a.value = "new value"
b.value = "new value"
println(a.value)
println(b.value)
}
}
Can anyone explain the difference between def and val in this
situation? Playing around with both I cannot find any difference
between 'a' and 'b', they are both the same class. But 'a' must be
something different. What exactly is it then?
Cheers,
Christoph