Last active
August 24, 2017 10:20
-
-
Save ljank/e9117819e583fcc1cf0a44ac722bf77e to your computer and use it in GitHub Desktop.
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
scala> class Parent { def f = this } | |
defined class Parent | |
scala> class Child extends Parent { def newF = this } | |
defined class Child | |
scala> val c = new Child | |
c: Child = Child@5b966ac7 | |
scala> c.newF | |
res4: Child = Child@5b966ac7 | |
scala> c.f.newF | |
<console>:11: error: value newF is not a member of Parent | |
c.f.newF | |
^ |
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
scala> class Parent { def f: this.type = this } | |
defined class Parent | |
scala> class Child extends Parent { def newF = this } | |
defined class Child | |
scala> val c = new Child | |
c: Child = Child@40452835 | |
scala> c.f.newF | |
res7: Child = Child@40452835 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment