Create an Ior
from an Either
.
Create an Ior
from an Either
.
an Either
from which the Ior
should be created
Ior.Left if the Either
was a Left
,
or Ior.Right if the Either
was a Right
Example:
scala> Ior.fromEither(Left(1)) res0: Ior[Int, Nothing] = Left(1) scala> Ior.fromEither(Right('1')) res1: Ior[Nothing, Char] = Right(1)
Create an Ior
from two Options if at least one of them is defined.
Create an Ior
from two Options if at least one of them is defined.
an element (optional) for the left side of the Ior
an element (optional) for the right side of the Ior
None
if both oa
and ob
are None
. Otherwise Some
wrapping
an Ior.Left, Ior.Right, or Ior.Both if oa
, ob
, or both are
defined (respectively).
Example:
scala> Ior.fromOptions(Option.empty[String], Option.empty[Int]) res0: Option[Ior[String, Int]] = None scala> Ior.fromOptions(Option.empty[String], Some(42)) res1: Option[Ior[String, Int]] = Some(Right(42)) scala> Ior.fromOptions(Some("Error"), Option.empty[Int]) res2: Option[Ior[String, Int]] = Some(Left(Error)) scala> Ior.fromOptions(Some("Warning"), Some(42)) res3: Option[Ior[String, Int]] = Some(Both(Warning,42))