RightProjection (original) (raw)

scala.util.Either.RightProjection

Projects an Either into a Right.

Because Either is already right-biased, this class is not normally needed. (It is retained in the library for now for easy cross-compilation between Scala 2.11 and 2.12.)

Attributes

Deprecated

[Since version 2.13.0] Either is now right-biased, calls to `right` should be removed

Source

Either.scala

Graph

Supertypes

Members list

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

Attributes

Source

Either.scala

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.filterToOption(_ > 10) // Some(Right(12))
Right(7).right.filterToOption(_ > 10)  // None
Left(12).right.filterToOption(_ > 10)  // None

Attributes

Source

Either.scala

Binds the given function across Right.

Binds the given function across Right.

Value parameters

f

The function to bind across Right.

Attributes

Source

Either.scala

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

Attributes

Source

Either.scala

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

Value parameters

f

The side-effecting function to execute.

Attributes

Source

Either.scala

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

Attributes

Source

Either.scala

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)

Attributes

Source

Either.scala

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

Attributes

Source

Either.scala

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()

Attributes

Source

Either.scala

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

Attributes

Deprecated

[Since version 2.13.0] Use `filterToOption`, which more accurately reflects the return type

Source

Either.scala

Returns the value from this Right or throws NoSuchElementException if this is a Left.

Returns the value from this Right or throws NoSuchElementException if this is a Left.

Right(12).right.get // 12
Left(12).right.get // NoSuchElementException

Attributes

Throws

Deprecated

[Since version 2.13.0] Use `Either.toOption.get` instead

Source

Either.scala

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:

Product

Source

Product.scala

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:

Product

Source

Product.scala

In this article