is there anything out of the box to convert code t...
# announcements
i
is there anything out of the box to convert code that can throw an exception to
Result
?
b
Copy code
val result = runCatching { some code }
i
ah, nice! I just realized that I'm using my own
Result
class and came up with my own:
Copy code
fun <T> toResult(f: () -> T): Result<T, Throwable> =
    try {
        Success(f())
    } catch (t: Throwable) {
        Failure(t)
    }
b
add
inline
to avoid object/class creation for lambda
i
thanks!