Returns false if Left or returns the result of the application of
the given function to the Right value.
Returns false if Left or returns the result of the application of
the given function to the Right value.
Right(12).right.exists(_ > 10) // true Right(7).right.exists(_ > 10) // false Left(12).right.exists(_ > 10) // false
Returns None if this is a Left or if the
given predicate p does not hold for the right value,
otherwise, returns a Right.
Returns None if this is a Left or if the
given predicate p does not hold for the right value,
otherwise, returns a Right.
Right(12).right.filter(_ > 10) // Some(Right(12)) Right(7).right.filter(_ > 10) // None Left(12).right.filter(_ > 10) // None
Binds the given function across Right.
Binds the given function across Right.
The function to bind across Right.
Returns true if Left or returns the result of the application of
the given function to the Right value.
Returns true if Left or returns the result of the application of
the given function to the Right value.
Right(12).right.forall(_ > 10) // true Right(7).right.forall(_ > 10) // false Left(12).right.forall(_ > 10) // true
Executes the given side-effecting function if this is a Right.
Executes the given side-effecting function if this is a Right.
Right(12).right.foreach(x => println(x)) // prints "12" Left(12).right.foreach(x => println(x)) // doesn't print
The side-effecting function to execute.
Returns string formatted according to given format string.
Returns string formatted according to given format string.
Format strings are as for String.format
(@see java.lang.String.format).
Returns the value from this Right or throws
Predef.NoSuchElementException if this is a Left.
Returns the value from this Right or throws
Predef.NoSuchElementException if this is a Left.
Right(12).right.get // 12 Left(12).right.get // NoSuchElementException
if the projection is Left.
Returns the value from this Right or the given argument if this is a
Left.
Returns the value from this Right or the given argument if this is a
Left.
Right(12).right.getOrElse(17) // 12 Left(12).right.getOrElse(17) // 17
The given function is applied if this is a Right.
The given function is applied if this is a Right.
Right(12).right.map(x => "flower") // Result: Right("flower") Left(12).right.map(x => "flower") // Result: Left(12)
Returns a Some containing the Right value
if it exists or a None if this is a Left.
Returns a Some containing the Right value
if it exists or a None if this is a Left.
Right(12).right.toOption // Some(12) Left(12).right.toOption // None
Returns a Seq containing the Right value if
it exists or an empty Seq if this is a Left.
Returns a Seq containing the Right value if
it exists or an empty Seq if this is a Left.
Right(12).right.toSeq // Seq(12) Left(12).right.toSeq // Seq()
Projects an
Eitherinto aRight.This allows for-comprehensions over Either instances - for example
Continuing the analogy with scala.Option, a
RightProjectiondeclares thatRightshould be analogous toSomein some code.Analogous to
LeftProjection, see example usage in its documentation above.1.0, 11/10/2008