kittinunf / Result

The modelling for success/failure of operations in Kotlin and KMM (Kotlin Multiplatform Mobile)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide functions to unwrap value or error

CommanderTvis opened this issue · comments

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

Probably, what is the use case for this though? Can we not use the existing API that is already currently provided?

@kittinunf use case:

val myValue = result.unwrap { throw RuntimeException(it) }