【发布时间】:2013-12-03 14:33:47
【问题描述】:
在扩展外部类时是否可以覆盖内部特征的成员?喜欢
class Foo {
trait Bar {
def bar = Set("a", "b")
}
class Baz extends Bar
object Baz {
def apply() = new Baz
}
}
我能否以任何形式创建 f 的 Foo 实例,例如 f.Baz().bar == Set("c", "d")?
澄清:Foo 类是给定的,我无法更改。它调用Baz(),所以我也无法更改它。因此,可能无法在 Bar 或 Baz 中改进覆盖内容?
【问题讨论】:
标签: scala inheritance inner-classes overriding