有人可以解释一下为什么:
abstract class Super(var title: String)
class Sub(title: String) extends Super(title) {
def test = println(title)
}
val s = new Sub("a")
s.test
s.title = "b"
s.test
印刷:
a
a
代替:
a
b
?
有人可以解释一下为什么:
abstract class Super(var title: String)
class Sub(title: String) extends Super(title) {
def test = println(title)
}
val s = new Sub("a")
s.test
s.title = "b"
s.test
印刷:
a
a
代替:
a
b
?