0

我需要取 2 个值,Either<Throwable, Any>如果每个值都是Right.

因为arrow-kt 0.11.0有可能tupled

tupled(
     "Hello".right(), 
     "Word".right()
).map { params ->
     println(params.a + params.b) //go to map ONLY IF a and b are always right
}

但由于不推荐使用 tupledarrow-kt 0.12以支持 Kotlin 的 Pair 和 Triple ,因此我可以t figure out how to achieve the same without tupled 。

4

1 回答 1

6

您可以使用Either.zip

"hello".right().zip("world".right()) { a, b -> a + b } 
于 2021-11-07T15:37:15.560 回答