Skip to content

Instantly share code, notes, and snippets.

@SethTisue
Created December 24, 2015 15:39
Show Gist options
  • Save SethTisue/dacfc96fbc63d6583c60 to your computer and use it in GitHub Desktop.
Save SethTisue/dacfc96fbc63d6583c60 to your computer and use it in GitHub Desktop.
make your implicit classes `val` parameters `private`
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