Movatterモバイル変換


[0]ホーム

URL:


Scala 3
3.7.4
LearnInstallPlaygroundFind A LibraryCommunityBlog
Scala 3
LearnInstallPlaygroundFind A LibraryCommunityBlog
DocsAPI
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL
Scala 3/scala/scala.util/Either/RightProjection

RightProjection

scala.util.Either.RightProjection
final caseclassRightProjection[+A,+B](e:Either[A,B])

Projects anEither into aRight.

BecauseEither 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
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all

Members list

Value members

Concrete methods

Returnsfalse ifLeft or returns the result of the application of the given function to theRight value.

Returnsfalse ifLeft or returns the result of the application of the given function to theRight value.

Right(12).right.exists(_ > 10)  // trueRight(7).right.exists(_ > 10)   // falseLeft(12).right.exists(_ > 10)   // false

Attributes

Source
Either.scala
deffilterToOption[A1](p:B=>Boolean):Option[Either[A1,B]]

ReturnsNone if this is aLeft or if the given predicatep does not hold for the right value, otherwise, returns aRight.

ReturnsNone if this is aLeft or if the given predicatep does not hold for the right value, otherwise, returns aRight.

Right(12).right.filterToOption(_ > 10) // Some(Right(12))Right(7).right.filterToOption(_ > 10)  // NoneLeft(12).right.filterToOption(_ > 10)  // None

Attributes

Source
Either.scala
defflatMap[A1 >:A,B1](f:B=>Either[A1,B1]):Either[A1,B1]

Binds the given function acrossRight.

Binds the given function acrossRight.

Value parameters

f

The function to bind acrossRight.

Attributes

Source
Either.scala

Returnstrue ifLeft or returns the result of the application of the given function to theRight value.

Returnstrue ifLeft or returns the result of the application of the given function to theRight value.

Right(12).right.forall(_ > 10) // trueRight(7).right.forall(_ > 10)  // falseLeft(12).right.forall(_ > 10)  // true

Attributes

Source
Either.scala
defforeach[U](f:B=>U):Unit

Executes the given side-effecting function if this is aRight.

Executes the given side-effecting function if this is aRight.

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
defgetOrElse[B1 >:B](or:=>B1):B1

Returns the value from thisRight or the given argument if this is aLeft.

Returns the value from thisRight or the given argument if this is aLeft.

Right(12).right.getOrElse(17) // 12Left(12).right.getOrElse(17)  // 17

Attributes

Source
Either.scala
defmap[B1](f:B=>B1):Either[A,B1]

The given function is applied if this is aRight.

The given function is applied if this is aRight.

Right(12).right.map(x => "flower") // Result: Right("flower")Left(12).right.map(x => "flower")  // Result: Left(12)

Attributes

Source
Either.scala

Returns aSome containing theRight value if it exists or aNone if this is aLeft.

Returns aSome containing theRight value if it exists or aNone if this is aLeft.

Right(12).right.toOption // Some(12)Left(12).right.toOption // None

Attributes

Source
Either.scala
deftoSeq:Seq[B]

Returns aSeq containing theRight value if it exists or an emptySeq if this is aLeft.

Returns aSeq containing theRight value if it exists or an emptySeq if this is aLeft.

Right(12).right.toSeq // Seq(12)Left(12).right.toSeq // Seq()

Attributes

Source
Either.scala

Deprecated methods

deffilter[A1](p:B=>Boolean):Option[Either[A1,B]]

ReturnsNone if this is aLeft or if the given predicatep does not hold for the right value, otherwise, returns aRight.

ReturnsNone if this is aLeft or if the given predicatep does not hold for the right value, otherwise, returns aRight.

Right(12).right.filter(_ > 10) // Some(Right(12))Right(7).right.filter(_ > 10)  // NoneLeft(12).right.filter(_ > 10)  // None

Attributes

Deprecated
[Since version 2.13.0]Use `filterToOption`, which more accurately reflects the return type
Source
Either.scala
defget:B

Returns the value from thisRight or throwsNoSuchElementException if this is aLeft.

Returns the value from thisRight or throwsNoSuchElementException if this is aLeft.

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

Attributes

Throws

NoSuchElementExceptionif the projection isLeft.

Deprecated
[Since version 2.13.0]Use `Either.toOption.get` instead
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.

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, anIterator[Any]

Inherited from:
Product
Source
Product.scala
In this article
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL

[8]ページ先頭

©2009-2025 Movatter.jp