Function2
scala.Function2
A function of 2 parameters.
In the following example, the definition of max
is shorthand, conceptually, for the anonymous class definition anonfun2
, although the implementation details of how the function value is constructed may differ:
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))
}
Attributes
- Source
- Function2.scala
- Graph
-
- Supertypes
- Known subtypes
-
class FromJavaBinaryOperator[T]class FromJavaObjDoubleConsumer[T]class FromJavaObjIntConsumer[T]class FromJavaObjLongConsumer[T]trait JFunction2$mcDDD$sptrait JFunction2$mcDDI$sptrait JFunction2$mcDDJ$sptrait JFunction2$mcDID$sptrait JFunction2$mcDII$sptrait JFunction2$mcDIJ$sptrait JFunction2$mcDJD$sptrait JFunction2$mcDJI$sptrait JFunction2$mcDJJ$sptrait JFunction2$mcFDD$sptrait JFunction2$mcFDI$sptrait JFunction2$mcFDJ$sptrait JFunction2$mcFID$sptrait JFunction2$mcFII$sptrait JFunction2$mcFIJ$sptrait JFunction2$mcFJD$sptrait JFunction2$mcFJI$sptrait JFunction2$mcFJJ$sptrait JFunction2$mcIDD$sptrait JFunction2$mcIDI$sptrait JFunction2$mcIDJ$sptrait JFunction2$mcIID$sptrait JFunction2$mcIII$sptrait JFunction2$mcIIJ$sptrait JFunction2$mcIJD$sptrait JFunction2$mcIJI$sptrait JFunction2$mcIJJ$sptrait JFunction2$mcJDD$sptrait JFunction2$mcJDI$sptrait JFunction2$mcJDJ$sptrait JFunction2$mcJID$sptrait JFunction2$mcJII$sptrait JFunction2$mcJIJ$sptrait JFunction2$mcJJD$sptrait JFunction2$mcJJI$sptrait JFunction2$mcJJJ$sptrait JFunction2$mcVDD$sptrait JFunction2$mcVDI$sptrait JFunction2$mcVDJ$sptrait JFunction2$mcVID$sptrait JFunction2$mcVII$sptrait JFunction2$mcVIJ$sptrait JFunction2$mcVJD$sptrait JFunction2$mcVJI$sptrait JFunction2$mcVJJ$sptrait JFunction2$mcZDD$sptrait JFunction2$mcZDI$sptrait JFunction2$mcZDJ$sptrait JFunction2$mcZID$sptrait JFunction2$mcZII$sptrait JFunction2$mcZIJ$sptrait JFunction2$mcZJD$sptrait JFunction2$mcZJI$sptrait JFunction2$mcZJJ$sp
- Self type
-
(T1, T2) => R
Members list
In this article