Last active
December 27, 2016 18:24
-
-
Save kevinmeredith/6a7e272a5ed1b7f4bc25c1756a818919 to your computer and use it in GitHub Desktop.
private versus private [this] in Scala 2.11
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> :paste | |
| // Entering paste mode (ctrl-D to finish) | |
| class A(private [this] val x: Int) | |
| object A { | |
| def f(a: A) = a.x | |
| } | |
| // Exiting paste mode, now interpreting. | |
| <console>:13: error: value x is not a member of A | |
| def f(a: A) = a.x | |
| ^ | |
| scala> :paste | |
| // Entering paste mode (ctrl-D to finish) | |
| class B(private val x: Int) | |
| object B { | |
| def f(b: B) = b.x | |
| } | |
| // Exiting paste mode, now interpreting. | |
| defined class B | |
| defined object B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment