Skip to content

Instantly share code, notes, and snippets.

@heathermiller
Created June 27, 2012 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heathermiller/3004947 to your computer and use it in GitHub Desktop.
Save heathermiller/3004947 to your computer and use it in GitHub Desktop.
Try.transform implementation
/** 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