Skip to content

Instantly share code, notes, and snippets.

@ashkrit
Created July 26, 2019 00:38
Show Gist options
  • Select an option

  • Save ashkrit/52821f2faca98c2c9cc88e07a622f58c to your computer and use it in GitHub Desktop.

Select an option

Save ashkrit/52821f2faca98c2c9cc88e07a622f58c to your computer and use it in GitHub Desktop.
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