您的位置:首页 > 其它

线性化很可怕,结果原来是这样的,尽量少用

2012-08-27 17:39 113 查看
abstract class Root {
def hello(s: String)
}

class SubA extends Root {
def hello(s: String) {
println("Hello,SubA! " + s)
}
}

trait D extends Root {
abstract override def hello(s: String) {

super.hello("traitd " + s);
}
}

trait E extends Root {
abstract override def hello(s: String) {

super.hello("traitd" + s);
}
}

object Main extends App {

val f = new SubA with D with E
f.hello("--")
}
我以为是"Hello,SubA! traitd -- traite --"
却原来是“Hello,SubA! traitd traite--”
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: