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

ChainingOps

scala.util.ChainingOps
finalclassChainingOps[A](self:A) extendsAnyVal

Adds chaining methodstap andpipe to every type.

Attributes

Source
ChainingOps.scala
Graph
Supertypes
classAnyVal
traitMatchable
classAny

Members list

Value members

Concrete methods

defpipe[B](f:A=>B):B

Converts the value by applying the functionf.

Converts the value by applying the functionf.

scala> import scala.util.chaining._scala> val times6 = (_: Int) * 6times6: Int => Int = $$Lambda$2023/975629453@17143b3bscala> val i = (1 - 2 - 3).pipe(times6).pipe(scala.math.abs)i: Int = 24

Note:(1 - 2 - 3).pipe(times6) may have a small amount of overhead at runtime compared to the equivalent{ val temp = 1 - 2 - 3; times6(temp) }.

Type parameters

B

the result type of the functionf.

Value parameters

f

the function to apply to the value.

Attributes

Returns

a new value resulting from applying the given functionf to this value.

Source
ChainingOps.scala
deftap[U](f:A=>U):A

Appliesf to the value for its side effects, and returns the original value.

Appliesf to the value for its side effects, and returns the original value.

scala> import scala.util.chaining._scala> val xs = List(1, 2, 3).tap(ys => println("debug " + ys.toString))debug List(1, 2, 3)xs: List[Int] = List(1, 2, 3)

Type parameters

U

the result type of the functionf.

Value parameters

f

the function to apply to the value.

Attributes

Returns

the original valueself.

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

[8]ページ先頭

©2009-2025 Movatter.jp