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/LeftProjection

LeftProjection

scala.util.Either.LeftProjection
final caseclassLeftProjection[+A,+B](e:Either[A,B])

Projects anEither into aLeft.

Attributes

See also
Source
Either.scala
Graph
Supertypes
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all

Members list

Value members

Concrete methods

Returnsfalse ifRight or returns the result of the application of the given function to theLeft value.

Returnsfalse ifRight or returns the result of the application of the given function to theLeft value.

Left(12).left.exists(_ > 10)  // trueLeft(7).left.exists(_ > 10)   // falseRight(12).left.exists(_ > 10) // false

Attributes

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

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

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

Left(12).left.filterToOption(_ > 10)  // Some(Left(12))Left(7).left.filterToOption(_ > 10)   // NoneRight(12).left.filterToOption(_ > 10) // None

Attributes

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

Binds the given function acrossLeft.

Binds the given function acrossLeft.

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 acrossLeft.

Attributes

Source
Either.scala

Returnstrue ifRight or returns the result of the application of the given function to theLeft value.

Returnstrue ifRight or returns the result of the application of the given function to theLeft value.

Left(12).left.forall(_ > 10)  // trueLeft(7).left.forall(_ > 10)   // falseRight(12).left.forall(_ > 10) // true

Attributes

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

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

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

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.

Attributes

Source
Either.scala
defgetOrElse[A1 >:A](or:=>A1):A1

Returns the value from thisLeft or the given argument if this is aRight.

Returns the value from thisLeft or the given argument if this is aRight.

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

Attributes

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

Maps the function argument throughLeft.

Maps the function argument throughLeft.

Left(12).left.map(_ + 2) // Left(14)Right[Int, Int](12).left.map(_ + 2) // Right(12)

Attributes

Source
Either.scala

Returns aSome containing theLeft value if it exists or aNone if this is aRight.

Returns aSome containing theLeft value if it exists or aNone if this is aRight.

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

Attributes

Source
Either.scala
deftoSeq:Seq[A]

Returns aSeq containing theLeft value if it exists or an emptySeq if this is aRight.

Returns aSeq containing theLeft value if it exists or an emptySeq if this is aRight.

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

Attributes

Source
Either.scala

Deprecated methods

deffilter[B1](p:A=>Boolean):Option[Either[A,B1]]

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

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

Left(12).left.filter(_ > 10)  // Some(Left(12))Left(7).left.filter(_ > 10)   // NoneRight(12).left.filter(_ > 10) // None

Attributes

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

Returns the value from thisLeft or throwsNoSuchElementException if this is aRight.

Returns the value from thisLeft or throwsNoSuchElementException if this is aRight.

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

Attributes

Throws
Deprecated
[Since version 2.13.0]use `Either.swap.getOrElse` 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