Created
October 1, 2020 22:37
-
-
Save byF/ff46914fab68ee1d98c5dcc384171906 to your computer and use it in GitHub Desktop.
Oh Scala, I wish Try's getOrElse could access the throwable in the "else" block by default
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
implicit class RichTry[T](val poorTry: Try[T]) extends AnyVal { | |
def getOrElseT[U >: T](default: Throwable => U): U = poorTry.fold(default, x => x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment