trait Function2

[source: scala/Function2.scala]

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

Function with 2 parameters.

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

  object Main extends Application {

    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

    println(max(0, 1))
    println(anonfun2(0, 1))
Direct Known Subclasses:
Exit, ReplyTo, SendTo, Node, DocCons, DocNest, ConsRHS, OffsetPosition, ProcInstr, DEFAULT, ParsedEntityDecl, AttListDecl, NotationDecl, ElemDecl, ParameterEntityDecl, PublicID, EvElemEnd, EvProcInstr

Method Summary
abstract def apply (v1 : T1, v2 : T2) : R
def curry : (T1) => (T2) => R
f(x1,x2) == (f.curry)(x1)(x2)
override def toString : java.lang.String
Methods inherited from AnyRef
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
abstract def apply(v1 : T1, v2 : T2) : R

override def toString : java.lang.String

def curry : (T1) => (T2) => R
f(x1,x2) == (f.curry)(x1)(x2)