Skip to content

Instantly share code, notes, and snippets.

@petitviolet
Created January 24, 2017 03:56
Show Gist options
  • Select an option

  • Save petitviolet/ac06c573a870118dc57a831545ace180 to your computer and use it in GitHub Desktop.

Select an option

Save petitviolet/ac06c573a870118dc57a831545ace180 to your computer and use it in GitHub Desktop.
how works `abstract override def`
trait Hoge {
def receive: String
}
trait HogeChild extends Hoge {
abstract override def receive: String = {
println(s"child")
super.receive
}
}
// class HogeImpl extends HogeChild {
class HogeImpl extends Hoge {
override def receive: String = {
println(s"impl")
"impl!!!"
}
}
val impl = new HogeImpl with HogeChild
impl.receive
```
> $ impl.receive
> child
> impl
> res1: String = "impl!!!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment