Function0
scala.Function0
A function of 0 parameters.
In the following example, the definition of greeting
is shorthand, conceptually, for the anonymous class definition anonfun0
, although the implementation details of how the function value is constructed may differ:
object Main extends App {
val name = "world"
val greeting = () => s"hello, $name"
val anonfun0 = new Function0[String] {
def apply(): String = s"hello, $name"
}
assert(greeting() == anonfun0())
}
Attributes
- Source
- Function0.scala
- Graph
-
- Supertypes
- Known subtypes
-
class FromJavaBooleanSupplierclass FromJavaDoubleSupplierclass FromJavaIntSupplierclass FromJavaLongSupplierclass FromJavaSupplier[T]trait Reference[T]trait ReferenceWrapper[T]class PhantomReference[T]class SoftReference[T]class WeakReference[T]trait JFunction0$mcB$sptrait JFunction0$mcC$sptrait JFunction0$mcD$sptrait JFunction0$mcF$sptrait JFunction0$mcI$sptrait JFunction0$mcJ$sptrait JFunction0$mcS$sptrait JFunction0$mcV$sptrait JFunction0$mcZ$spclass AbstractFunction0[R]
- Self type
-
() => R
Members list
In this article