Projects an Either
into a Left
.
Projects an Either
into a Right
.
If the condition is satisfied, return the given B
in Right
,
otherwise, return the given A
in Left
.
If the condition is satisfied, return the given B
in Right
,
otherwise, return the given A
in Left
.
val userInput: String = ... Either.cond( userInput.forall(_.isDigit) && userInput.size == 10, PhoneNumber(userInput), "The input (%s) does not look like a phone number".format(userInput)
Allows use of a
method to extract values from Either instances
regardless of whether they are Left or Right.merge
Allows use of a
method to extract values from Either instances
regardless of whether they are Left or Right.merge
val l = Left(List(1)): Either[List[Int], Vector[Int]] val r = Right(Vector(1)): Either[List[Int], Vector[Int]] l.merge: Seq[Int] // List(1) r.merge: Seq[Int] // Vector(1)
(Since version 2.8.0) use x.joinLeft'
(Since version 2.8.0) use x.joinRight'
Takes an Either
to its contained value within Left
or
Right
.
Takes an Either
to its contained value within Left
or
Right
.
(Since version 2.8.0) use x.merge'