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

Failure

scala.util.Failure
final caseclassFailure[+T](exception:Throwable) extendsTry[T]

Attributes

Source
Try.scala
Graph
Supertypes
classTry[T]
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all

Members list

Type members

Inherited classlikes

finalclassWithFilter(p:Try.this.T=>Boolean)

We need a whole WithFilter class to honor the "doesn't create a new collection" contract even though it seems unlikely to matter much in a collection with max size 1.

We need a whole WithFilter class to honor the "doesn't create a new collection" contract even though it seems unlikely to matter much in a collection with max size 1.

Attributes

Inherited from:
Try
Source
Try.scala
Supertypes
classObject
traitMatchable
classAny

Value members

Concrete methods

overridedefcollect[U](pf:PartialFunction[T,U]):Try[U]

Applies the given partial function to the value from thisSuccess or returns this if this is aFailure.

Applies the given partial function to the value from thisSuccess or returns this if this is aFailure.

Attributes

Definition Classes
Source
Try.scala
overridedeffailed:Try[Throwable]

Inverts thisTry.

Inverts thisTry. If this is aFailure, returns its exception wrapped in aSuccess. If this is aSuccess, returns aFailure containing anUnsupportedOperationException.

Attributes

Definition Classes
Source
Try.scala
overridedeffilter(p:T=>Boolean):Try[T]

Converts this to aFailure if the predicate is not satisfied.

Converts this to aFailure if the predicate is not satisfied.

Attributes

Definition Classes
Source
Try.scala
overridedefflatMap[U](f:T=>Try[U]):Try[U]

Returns the given function applied to the value from thisSuccess or returns this if this is aFailure.

Returns the given function applied to the value from thisSuccess or returns this if this is aFailure.

Attributes

Definition Classes
Source
Try.scala
overridedefflatten[U](implicitev:T<:<Try[U]):Try[U]

Transforms a nestedTry, ie, aTry of typeTry[Try[T]], into an un-nestedTry, ie, aTry of typeTry[T].

Transforms a nestedTry, ie, aTry of typeTry[Try[T]], into an un-nestedTry, ie, aTry of typeTry[T].

Attributes

Definition Classes
Source
Try.scala
overridedeffold[U](fa:Throwable=>U,fb:T=>U):U

Appliesfa if this is aFailure orfb if this is aSuccess.

Appliesfa if this is aFailure orfb if this is aSuccess. Iffb is initially applied and throws an exception, thenfa is applied with this exception.

Value parameters

fa

the function to apply if this is aFailure

fb

the function to apply if this is aSuccess

Attributes

Returns

the results of applying the function

Example

val result: Try[Int] = Try { string.toInt }log(result.fold( ex => "Operation failed with " + ex, v => "Operation produced value: " + v))
Definition Classes
Source
Try.scala
overridedefforeach[U](f:T=>U):Unit

Applies the given functionf if this is aSuccess, otherwise returnsUnit if this is aFailure.

Applies the given functionf if this is aSuccess, otherwise returnsUnit if this is aFailure.

Note: Iff throws, then this method may throw an exception.

Attributes

Definition Classes
Source
Try.scala
overridedefget:T

Returns the value from thisSuccess or throws the exception if this is aFailure.

Returns the value from thisSuccess or throws the exception if this is aFailure.

Attributes

Definition Classes
Source
Try.scala
overridedefgetOrElse[U >:T](default:=>U):U

Returns the value from thisSuccess or the givendefault argument if this is aFailure.

Returns the value from thisSuccess or the givendefault argument if this is aFailure.

Note:: This will throw an exception if it is not a success and default throws an exception.

Attributes

Definition Classes
Source
Try.scala
overridedefisFailure:Boolean

Returnstrue if theTry is aFailure,false otherwise.

Returnstrue if theTry is aFailure,false otherwise.

Attributes

Definition Classes
Source
Try.scala
overridedefisSuccess:Boolean

Returnstrue if theTry is aSuccess,false otherwise.

Returnstrue if theTry is aSuccess,false otherwise.

Attributes

Definition Classes
Source
Try.scala
overridedefmap[U](f:T=>U):Try[U]

Maps the given function to the value from thisSuccess or returns this if this is aFailure.

Maps the given function to the value from thisSuccess or returns this if this is aFailure.

Attributes

Definition Classes
Source
Try.scala
overridedeforElse[U >:T](default:=>Try[U]):Try[U]

Returns thisTry if it's aSuccess or the givendefault argument if this is aFailure.

Returns thisTry if it's aSuccess or the givendefault argument if this is aFailure.

Attributes

Definition Classes
Source
Try.scala
overridedefrecover[U >:T](pf:PartialFunction[Throwable,U]):Try[U]

Applies the given functionf if this is aFailure, otherwise returns this if this is aSuccess.

Applies the given functionf if this is aFailure, otherwise returns this if this is aSuccess. This is like map for the exception.

Attributes

Definition Classes
Source
Try.scala
overridedefrecoverWith[U >:T](pf:PartialFunction[Throwable,Try[U]]):Try[U]

Applies the given functionf if this is aFailure, otherwise returns this if this is aSuccess.

Applies the given functionf if this is aFailure, otherwise returns this if this is aSuccess. This is likeflatMap for the exception.

Attributes

Definition Classes
Source
Try.scala
overridedeftoEither:Either[Throwable,T]

ReturnsLeft withThrowable if this is aFailure, otherwise returnsRight withSuccess value.

ReturnsLeft withThrowable if this is aFailure, otherwise returnsRight withSuccess value.

Attributes

Definition Classes
Source
Try.scala
overridedeftoOption:Option[T]

ReturnsNone if this is aFailure or aSome containing the value if this is aSuccess.

ReturnsNone if this is aFailure or aSome containing the value if this is aSuccess.

Attributes

Definition Classes
Source
Try.scala
overridedeftransform[U](s:T=>Try[U],f:Throwable=>Try[U]):Try[U]

Completes thisTry by applying the functionf to this if this is of typeFailure, or conversely, by applyings if this is aSuccess.

Completes thisTry by applying the functionf to this if this is of typeFailure, or conversely, by applyings if this is aSuccess.

Attributes

Definition Classes
Source
Try.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

Creates a non-strict filter, which eventually converts this to aFailure if the predicate is not satisfied.

Creates a non-strict filter, which eventually converts this to aFailure if the predicate is not satisfied.

Note: unlike filter, withFilter does not create a new Try. Instead, it restricts the domain of subsequentmap,flatMap,foreach, andwithFilter operations.

As Try is a one-element collection, this may be a bit overkill, but it's consistent with withFilter on Option and the other collections.

Value parameters

p

the predicate used to test elements.

Attributes

Returns

an object of classWithFilter, which supportsmap,flatMap,foreach, andwithFilter operations. All these operations apply to those elements of this Try which satisfy the predicatep.

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

[8]ページ先頭

©2009-2025 Movatter.jp