ToRightDisjunction in cats

I have not found a function like toRightDisjunction

in scalaz

to convert Option

to Either

. Why cats

doesn't it provide such a function?

+3


source to share


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







All Articles