假设我有一个基本特征,我的特征是扩展基本特征。我想用mix-in self =>创建一个类。 trait可以动态调用重载。
答案 0 :(得分:1)
Int(percent
输出将是:
package minxin.neel.test
/**
* Created by Neelamadhab.
*/
class TestMix2 {
def hello = println("Hello NEEL...")
}
class BaseMixInClass {
self: BaseTrait =>
self.method
}
trait BaseTrait {
def method = println("Inside method in BaseTrait")
}
trait Trait2 extends BaseTrait {
override def method = println("Hello, Inside method in Trait2")
}
trait Trait3 extends BaseTrait {
override def method = println("Hello, Inside method in Trait3")
}
trait Trait4 extends BaseTrait
object MyMixinTest extends App {
new BaseMixInClass with Trait2
new BaseMixInClass with Trait3
new BaseMixInClass with Trait4
new BaseMixInClass with BaseTrait
}