a guest Apr 19th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. val tFail: Try[String] = Try(throw new Exception("I failed!"))
  2. // tFail: scala.util.Try[String] = Failure(java.lang.Exception: I failed!)
  3. val tThrow = tFail.failed
  4. // tThrow: scala.util.Try[Throwable] = Success(java.lang.Exception: I failed!)
  5. val tSuccess = Try("Everything okay!")
  6. // tSuccess: scala.util.Try[String] = Success(Everything okay!)
  7. val tThrow2 = tSuccess.failed
  8. // tThrow2: scala.util.Try[Throwable] = Failure(java.lang.UnsupportedOperationException: Success.failed)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand