When using Either: Is there an easier way to fall back to another Either if the first one is Left? I have this
Copy code
val either1 = Either.catch { ... /* some logic here*/ }
val either2 = Either.catch { ... /* some fallback logic here*/ }
val either = if (either1.isRight()) either1 else either2
I thought there would be a function to chain the eithers somehow...
y
Youssef Shoaib [MOD]
01/31/2024, 3:22 PM
Copy code
either1.recover { either2.bind() }
➕ 2
d
Daniel TIefenauer
01/31/2024, 3:25 PM
that's it! thx!!
.bind
somehow fails to show in IntelliJ code completion...
y
Youssef Shoaib [MOD]
01/31/2024, 3:26 PM
It's an extension defined inside
Raise
, but I would expect it to still show up. That's strange. Might be something solved in K2