Adds chaining methodstap andpipe to every type.
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 = 24Note:(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) }.
the result type of the functionf.
the function to apply to the value.
a new value resulting from applying the given functionf to this value.
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)the result type of the functionf.
the function to apply to the value.
the original valueself.