I need to take 2 values, each of them is Either<Throwable, Any>
and combine them together (or to do anything else) if each of the values is Right
.
For arrow-kt 0.11.0
it was possible with tupled
tupled(
"Hello".right(),
"Word".right()
).map { params ->
println(params.a params.b) //go to map ONLY IF a and b are always right
}
but since arrow-kt 0.12
tupled is deprecated in favor of Kotlin's Pair and Triple and I cant figure out how to achieve the same without
tupled`.
CodePudding user response:
You can use Either.zip
"hello".right().zip("world".right()) { a, b -> a b }