Created
July 26, 2019 00:38
-
-
Save ashkrit/52821f2faca98c2c9cc88e07a622f58c 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
| def main(args: Array[String]): Unit = { | |
| val res = divide(10, 0) | |
| res match { | |
| case Left(value) => println(s"Result is ${value}") | |
| case Right(e) => println(s"Calculation failed reason ${e}") | |
| } | |
| val result = trydivide(10, 0) | |
| result match { | |
| case Success(r) => println(s"Result ${r}") | |
| case Failure(error) => println(s"Failed to calculate reason : ${error.getMessage}") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment