Created
November 8, 2019 17:37
-
-
Save deeperunderstanding/a75ba8756ea67d719308d30a1aa42c2d to your computer and use it in GitHub Desktop.
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
object TrySequence { | |
operator fun <T> Try<T>.component1(): T = when (this) { | |
is Success -> this.value | |
is Failure -> throw this.error | |
} | |
} | |
fun <T> Try.Companion.sequential(func: TrySequence.() -> T): Try<T> { | |
return Try { func(TrySequence) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment