https://kotlinlang.org logo
#arrow
Title
# arrow
a

Archie

09/09/2022, 2:50 AM
Hi very new in using Arrow. Was wondering how to handle scenario where I have two
Either
and both have to be
right
for me to do proper computation?
Is this correct?
Copy code
suspend fun test() = either {
   val r1 = Either.Right(1).bind()
   val r2 = Either.Right(2).bind()"

    r1 + r2        
}
Thanks in advance
y

Youssef Shoaib [MOD]

09/09/2022, 4:58 AM
Yes, or you could do
Either.Right(1).zip(Either.Right(2)) {a, b -> a + b }
a

Archie

09/09/2022, 5:02 AM
Ah! Thank you very much!