如何在 Scala 中预初始化一个 val 并扩展一个类?
例如:
object Start {
def main(args: Array[String]): Unit = {
new T()
new T2()
//T3?
}
}
class T extends{val z = 10} with X with Y
class T2 extends X with Y {val z=10}
//class T3 extends{val z = 10} ??? Z with X with Y //????
class Z
trait X {
val z :Int
}
trait Y { this :X =>
println("Test: "+z)
}