Last active
March 21, 2019 18:08
-
-
Save girdharshubham/dd445d34daba348fa8bcacd4d9047388 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 = new PartialFunction[Int, Int] { | |
override def isDefinedAt(number: Int): Boolean = number == 21 | |
override def apply(number: Int) = number * 2 | |
} | |
val deepThoughQuery = deepThoughtProcessor isDefinedAt 22 // res0 = false | |
val lifeUniverseEverything = deepThoughtProcessor apply 21 //res1 = 42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment