Created
December 24, 2015 15:39
-
-
Save SethTisue/dacfc96fbc63d6583c60 to your computer and use it in GitHub Desktop.
make your implicit classes `val` parameters `private`
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
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_66). | |
scala> implicit class Foo(val x: Int) { def foo = x * 2 } | |
defined class Foo | |
scala> 3.x | |
res0: Int = 3 | |
scala> :reset | |
Resetting interpreter state. | |
Forgetting defined types: Foo | |
scala> implicit class Foo(private val x: Int) { def foo = x * 2 } | |
defined class Foo | |
scala> 3.x | |
<console>:12: error: value x is not a member of Int | |
3.x | |
^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment