Class

scala.util

ChainingOps

Related Doc: package util

Permalink

final class ChainingOps[A] extends AnyVal

Adds chaining methods tap and pipe to every type.

Linear Supertypes
AnyVal, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ChainingOps
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ChainingOps(self: A)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def getClass(): Class[_ <: AnyVal]

    Permalink
    Definition Classes
    AnyVal → Any
  6. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  7. def pipe[B](f: (A) ⇒ B): B

    Permalink

    Converts the value by applying the function f.

    Converts the value by applying the function f.

    scala> import scala.util.chaining._
    
    scala> val times6 = (_: Int) * 6
    times6: Int => Int = $$Lambda$2023/975629453@17143b3b
    
    scala> 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) }.

    B

    the result type of the function f.

    f

    the function to apply to the value.

    returns

    a new value resulting from applying the given function f to this value.

  8. def tap[U](f: (A) ⇒ U): A

    Permalink

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

    Applies f 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)
    U

    the result type of the function f.

    f

    the function to apply to the value.

    returns

    the original value self.

  9. def toString(): String

    Permalink
    Definition Classes
    Any

Inherited from AnyVal

Inherited from Any

Ungrouped