Skip to content

Instantly share code, notes, and snippets.

@tstone
Last active August 29, 2015 13:57
Show Gist options
  • Save tstone/9746776 to your computer and use it in GitHub Desktop.
Save tstone/9746776 to your computer and use it in GitHub Desktop.
// Given
trait Common
class A extends Common
class B extends Common
class C extends Common
// These are equivalent...
implicit class CommonOps(c: Common) {
def getSomething = c match {
case a: A => ???
case b: B => ???
case c: C => ???
}
def getSomethingElse = c match {
case a: A => ???
case b: B => ???
case c: C => ???
}
}
// ----------------------
implicit class AOps(a: A) {
def getSomething = ???
def getSomethignElse = ???
}
implicit class BOps(b: B) {
def getSomething = ???
def getSomethignElse = ???
}
implicit class COps(c: C) {
def getSomething = ???
def getSomethignElse = ???
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment