Last active
June 20, 2020 22:02
-
-
Save Garyfimo/52c6e62a6c862ff4e672000e111f9235 to your computer and use it in GitHub Desktop.
This file contains 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
sealed class ResultadoEvaluacion<out E, out V> { | |
data class Valor<out V>(val valor: V) : ResultadoEvaluacion<Nothing, V>() | |
data class Error<out E>(val error: E) : ResultadoEvaluacion<E, Nothing>() | |
companion object { | |
inline fun <V> build(function: () -> V): ResultadoEvaluacion<Exception, V> = | |
try { | |
Valor( | |
function.invoke() | |
) | |
} catch (ex: Exception) { | |
Error( | |
ex | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment