Last active
March 21, 2019 18:56
-
-
Save girdharshubham/4955530df051f6183cb9b25ae20ac589 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
val deepThoughtProcessor: PartialFunction[Int, Int] = { | |
case number:Int if number == 21 => number*2 | |
} | |
deepThoughtProcessor isDefinedAt 22 // res0 = false | |
deepThoughtProcessor(21) // res1 = 42 | |
/* Now, if you still try to invoke deepThoughtProcessor with the argument | |
* it's not defined at you'd get a MatchError | |
**/ | |
deepThoughtProcessor(22) //MatchError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment