Created
October 14, 2016 18:57
-
-
Save jducoeur/5e99bbd06f16297e205112c261604e89 to your computer and use it in GitHub Desktop.
This file contains 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
sealed trait MyTrait | |
case class Impl1() extends MyTrait | |
case class Impl2() extends MyTrait | |
def recover1:PartialFunction[Any, Unit] = { | |
case s:String => println("It was a String") | |
case i:Int => println("It was an Int") | |
} | |
def recoverMyTrait:PartialFunction[MyTrait, Unit] = { | |
case Impl1() => println("Got an Impl1") | |
case Impl2() => println("Got an Impl2") | |
} | |
def recover:PartialFunction[Any, Unit] = | |
recover1 orElse recoverMyTrait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment