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

Either

scala.util.Either
See theEither companion class
objectEither

Attributes

Companion
class
Source
Either.scala
Graph
Supertypes
classObject
traitMatchable
classAny
Self type
Either.type

Members list

Type members

Classlikes

final caseclassLeftProjection[+A,+B](e:Either[A,B])

Projects anEither into aLeft.

Projects anEither into aLeft.

Attributes

See also
Source
Either.scala
Supertypes
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final implicitclassMergeableEither[A](x:Either[A,A]) extendsAnyVal

Allows use of amerge method to extract values from Either instances regardless of whether they are Left or Right.

Allows use of amerge method to extract values from Either instances regardless of whether they are Left or Right.

val l = Left(List(1)): Either[List[Int], Vector[Int]]val r = Right(Vector(1)): Either[List[Int], Vector[Int]]l.merge: Seq[Int] // List(1)r.merge: Seq[Int] // Vector(1)

Attributes

Source
Either.scala
Supertypes
classAnyVal
traitMatchable
classAny

Deprecated classlikes

final caseclassRightProjection[+A,+B](e:Either[A,B])

Projects anEither into aRight.

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

Value members

Concrete methods

defcond[A,B](test:Boolean,right:=>B,left:=>A):Either[A,B]

If the condition is satisfied, return the givenB inRight, otherwise, return the givenA inLeft.

If the condition is satisfied, return the givenB inRight, otherwise, return the givenA inLeft.

val userInput: String = readLine()Either.cond(  userInput.forall(_.isDigit) && userInput.size == 10,  PhoneNumber(userInput),  s"The input ($userInput) does not look like a phone number"

Attributes

Source
Either.scala

Implicits

Implicits

implicitdefMergeableEither[A](x:Either[A,A]):MergeableEither[A]

Allows use of amerge method to extract values from Either instances regardless of whether they are Left or Right.

Allows use of amerge method to extract values from Either instances regardless of whether they are Left or Right.

val l = Left(List(1)): Either[List[Int], Vector[Int]]val r = Right(Vector(1)): Either[List[Int], Vector[Int]]l.merge: Seq[Int] // List(1)r.merge: Seq[Int] // Vector(1)

Attributes

Source
Either.scala
In this article
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL

[8]ページ先頭

©2009-2025 Movatter.jp