Last active
August 29, 2015 13:57
-
-
Save tstone/9746776 to your computer and use it in GitHub Desktop.
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
// 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