Projects an Either
into a Left
.
Allows use of a merge
method to extract values from Either instances
regardless of whether they are Left or Right.
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)