我需要获取两个值,每个值都是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
}但是,由于元组被弃用,取而代之的是Kotlin的对和arrow-kt 0.12和我可以t figure out how to achieve the same without的元组`。
发布于 2021-11-07 15:37:16
您可以使用Either.zip
"hello".right().zip("world".right()) { a, b -> a + b } https://stackoverflow.com/questions/69873207
复制相似问题