Created
January 24, 2017 03:56
-
-
Save petitviolet/ac06c573a870118dc57a831545ace180 to your computer and use it in GitHub Desktop.
how works `abstract override def`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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