Skip to content

Instantly share code, notes, and snippets.

@edmundnoble
Created November 19, 2016 18:21
Show Gist options
  • Save edmundnoble/68e5cdc93947e914309a927dfb2748f2 to your computer and use it in GitHub Desktop.
Save edmundnoble/68e5cdc93947e914309a927dfb2748f2 to your computer and use it in GitHub Desktop.
scala> sealed trait B
defined trait B
scala> case class A(i: Int) extends B
defined class A
scala> implicit class AOps(a: A) {
| def stuff: Unit = println("A")
| }
defined class AOps
scala> implicit class BOps(b: B) {
| def stuff: Unit = println("B")
| }
defined class BOps
scala> A(1).stuff
A
scala> new B {}.stuff
B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment