Provide functions to unwrap value or error
CommanderTvis opened this issue · comments
Iaroslav Postovalov commented
It would be interesting to provide functions to unwrap value or error.
inline fun <V, E> Result<V, E>.unwrap(failure: (E) -> Nothing): T
inline fun <V, E> Result<V, E>.unwrapError(success: (V) -> Nothing): E
Kittinun Vantasin commented
Probably, what is the use case for this though? Can we not use the existing API that is already currently provided?
Iaroslav Postovalov commented
@kittinunf use case:
val myValue = result.unwrap { throw RuntimeException(it) }