scala.Function1
See theFunction1 companion object
A function of 1 parameter.
In the following example, the definition of succ is shorthand, conceptually, for the anonymous class definition anonfun1, although the implementation details of how the function value is constructed may differ:
val succ = (x: Int) => x + 1
val anonfun1 = new Function1[Int, Int] {
def apply(x: Int): Int = x + 1
}
assert(succ(0) == anonfun1(0))
Note that the difference between Function1 and scala.PartialFunction is that the latter can specify inputs which it will not handle.
Attributes
- Companion
- object
- Source
- Function1.scala
- Graph
-
- Supertypes
- Known subtypes
-
class FromJavaDoubleConsumerclass FromJavaDoublePredicateclass FromJavaIntConsumerclass FromJavaIntPredicateclass FromJavaIntUnaryOperatorclass FromJavaLongConsumerclass FromJavaLongPredicatetrait JFunction1$mcDD$sptrait JFunction1$mcDF$sptrait JFunction1$mcDI$sptrait JFunction1$mcDJ$sptrait JFunction1$mcFD$sptrait JFunction1$mcFF$sptrait JFunction1$mcFI$sptrait JFunction1$mcFJ$sptrait JFunction1$mcID$sptrait JFunction1$mcIF$sptrait JFunction1$mcII$sptrait JFunction1$mcIJ$sptrait JFunction1$mcJD$sptrait JFunction1$mcJF$sptrait JFunction1$mcJI$sptrait JFunction1$mcJJ$sptrait JFunction1$mcVD$sptrait JFunction1$mcVF$sptrait JFunction1$mcVI$sptrait JFunction1$mcVJ$sptrait JFunction1$mcZD$sptrait JFunction1$mcZF$sptrait JFunction1$mcZI$sptrait JFunction1$mcZJ$spobject StringViewobject ScalaReflectionExceptionobject UninitializedFieldErrorclass SystemPropertiesclass ofBooleanclass ofByteclass ofCharclass ofDoubleclass ofFloatclass ofIntclass ofLongclass ofShortclass ofUnitobject Nilclass Rangeclass Exclusiveclass Inclusiveobject Emptyclass WrappedStringclass ofBooleanclass ofByteclass ofCharclass ofDoubleclass ofFloatclass ofIntclass ofLongclass ofShortclass ofUnitclass StringBuilderclass DoubleAccumulatorclass IntAccumulatorclass LongAccumulator
Members list
In this article