Packages

t

scala

Function2

trait Function2[-T1, -T2, +R] extends AnyRef

A function of 2 parameters.

In the following example, the definition of max is a shorthand for the anonymous class definition anonfun2:

 object Main extends App {
   val max = (x: Int, y: Int) => if (x < y) y else x

   val anonfun2 = new Function2[Int, Int, Int] {
     def apply(x: Int, y: Int): Int = if (x < y) y else x
   }
   assert(max(0, 1) == anonfun2(0, 1))
}
Self Type
(T1, T2) => R
Source
Function2.scala
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Function2
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def apply(v1: T1, v2: T2): R

    Apply the body of this function to the arguments.

    Apply the body of this function to the arguments.

    returns

    the result of function application.

Concrete Value Members

  1. def curried: (T1) => (T2) => R

    Creates a curried version of this function.

    Creates a curried version of this function.

    returns

    a function f such that f(x1)(x2) == apply(x1, x2)

    Annotations
    @unspecialized()
  2. def toString(): String

    Creates a String representation of this object.

    Creates a String representation of this object. The default representation is platform dependent. On the java platform it is the concatenation of the class name, "@", and the object's hashcode in hexadecimal.

    returns

    a String representation of the object.

    Definition Classes
    Function2 → AnyRef → Any
  3. def tupled: ((T1, T2)) => R

    Creates a tupled version of this function: instead of 2 arguments, it accepts a single scala.Tuple2 argument.

    Creates a tupled version of this function: instead of 2 arguments, it accepts a single scala.Tuple2 argument.

    returns

    a function f such that f((x1, x2)) == f(Tuple2(x1, x2)) == apply(x1, x2)

    Annotations
    @unspecialized()