ToRightDisjunction in cats
1 answer
The scala library provides these functions via Option.toLeft
and Option.toRight
:
val s = "Oh no".some
val leftRes: Either[String, Int] = s.toLeft(42)
val rightRes: Either[Int, String] = s.toRight(42)
Since it Either[A, B]
became defacto standard in 2.12 (replacing Xor
) after the correct offset, there is no need for any additional extension methods.
+4
source to share