Created
June 27, 2012 15:46
-
-
Save heathermiller/3004947 to your computer and use it in GitHub Desktop.
Try.transform implementation
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
/** Completes this `Try` by applying the function `f` to this if this is of type `Failure`, or conversely, by applying | |
* `s` if this is a `Success`. | |
*/ | |
def transform[U](f: Throwable => Try[U], s: T => Try[U]): Try[U] = this match { | |
case Success(v) => s(v) | |
case Failure(e) => f(e) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment