zip
Combines this Result with other via combine, failing when either is a failure.
When both are failures the first failure wins: this receiver's exception is returned and other's exception is dropped. combine runs only when both are successes, and exceptions it throws are not caught.
val profile = loadUser(id).zip(loadAvatar(id)) { user, avatar -> Profile(user, avatar) }Content copied to clipboard
Return
a success holding the combined value, or the first failure.
Parameters
other
the second Result to combine with.
combine
mapping from both success values to the combined value.
inline fun <A, B, C, R> Result<A>.zip(second: Result<B>, third: Result<C>, combine: (A, B, C) -> R): Result<R>
Combines this Result with second and third via combine, failing when any is a failure.
The earliest failure in declaration order wins; later exceptions are dropped. combine runs only when all three are successes, and exceptions it throws are not caught.
Return
a success holding the combined value, or the earliest failure.