LeftProjection
Projects an Either
into a Left
.
- See also:
- Source:
- Either.scala
Value members
Concrete methods
Returns false
if Right
or returns the result of the application of
the given function to the Left
value.
Returns false
if Right
or returns the result of the application of
the given function to the Left
value.
Left(12).left.exists(_ > 10) // true
Left(7).left.exists(_ > 10) // false
Right(12).left.exists(_ > 10) // false
- Source:
- Either.scala
Returns None
if this is a Right
or if the given predicate
p
does not hold for the left value, otherwise, returns a Left
.
Returns None
if this is a Right
or if the given predicate
p
does not hold for the left value, otherwise, returns a Left
.
Left(12).left.filterToOption(_ > 10) // Some(Left(12))
Left(7).left.filterToOption(_ > 10) // None
Right(12).left.filterToOption(_ > 10) // None
- Source:
- Either.scala
Binds the given function across Left
.
Binds the given function across Left
.
Left(12).left.flatMap(x => Left("scala")) // Left("scala")
Right(12).left.flatMap(x => Left("scala")) // Right(12)
- Value parameters:
- f
The function to bind across
Left
.
- Source:
- Either.scala
Returns true
if Right
or returns the result of the application of
the given function to the Left
value.
Returns true
if Right
or returns the result of the application of
the given function to the Left
value.
Left(12).left.forall(_ > 10) // true
Left(7).left.forall(_ > 10) // false
Right(12).left.forall(_ > 10) // true
- Source:
- Either.scala
Executes the given side-effecting function if this is a Left
.
Executes the given side-effecting function if this is a Left
.
Left(12).left.foreach(x => println(x)) // prints "12"
Right(12).left.foreach(x => println(x)) // doesn't print
- Value parameters:
- f
The side-effecting function to execute.
- Source:
- Either.scala
Returns the value from this Left
or the given argument if this is a Right
.
Returns the value from this Left
or the given argument if this is a Right
.
Left(12).left.getOrElse(17) // 12
Right(12).left.getOrElse(17) // 17
- Source:
- Either.scala
Maps the function argument through Left
.
Maps the function argument through Left
.
Left(12).left.map(_ + 2) // Left(14)
Right[Int, Int](12).left.map(_ + 2) // Right(12)
- Source:
- Either.scala
Returns a Some
containing the Left
value if it exists or a
None
if this is a Right
.
Returns a Some
containing the Left
value if it exists or a
None
if this is a Right
.
Left(12).left.toOption // Some(12)
Right(12).left.toOption // None
- Source:
- Either.scala
Returns a Seq
containing the Left
value if it exists or an empty
Seq
if this is a Right
.
Returns a Seq
containing the Left
value if it exists or an empty
Seq
if this is a Right
.
Left(12).left.toSeq // Seq(12)
Right(12).left.toSeq // Seq()
- Source:
- Either.scala
Deprecated methods
Returns None
if this is a Right
or if the given predicate
p
does not hold for the left value, otherwise, returns a Left
.
Returns None
if this is a Right
or if the given predicate
p
does not hold for the left value, otherwise, returns a Left
.
Left(12).left.filter(_ > 10) // Some(Left(12))
Left(7).left.filter(_ > 10) // None
Right(12).left.filter(_ > 10) // None
- Deprecated
- Source:
- Either.scala
Returns the value from this Left
or throws NoSuchElementException
if this is a Right
.
Returns the value from this Left
or throws NoSuchElementException
if this is a Right
.
Left(12).left.get // 12
Right(12).left.get // NoSuchElementException
- Throws:
- NoSuchElementException
if the projection is scala.util.Right
- Deprecated
- Source:
- Either.scala
Inherited methods
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
- Inherited from:
- Product
- Source:
- Product.scala
An iterator over all the elements of this product.
An iterator over all the elements of this product.
- Returns:
in the default implementation, an
Iterator[Any]
- Inherited from:
- Product
- Source:
- Product.scala