class Blah{As I mentioned in the comment there, using super.foo calls the trait's version of foo(). But what if you want to call Blah's version of foo()?
def foo(){
}
}
trait Tleh{
def foo(){
}
}
class Dingle extends Blah with Tleh{
override def foo(){
super.foo // this calls Tleh.foo
}
}
It's actually pretty simple, and a bit intuitive if you know a bit of Scala:
class Dingle extends Blah with Tleh{This is pretty simple, but it took me a little while to figure it out since there doesn't seem to be any mention of this in the docs I found!
override def foo(){
super.foo // calls Tleh.foo
super[Blah].foo // calls Blah.foo
super[Tleh].foo // calls Tleh.foo
}
}
No comments:
Post a Comment