August 2018
Beginner
178 pages
4h 56m
English
Java doesn't have function types; instead, it uses interfaces with a single method or functional interfaces to achieve similar behavior. Kotlin compiles its function types to functional interfaces, called Function0, Function1, Function2, and so on. The number at the end represents the number of function parameters. Here is how they are defined in the Kotlin standard library. Don't worry about the angle brackets or in and out keywords; these are generic functions. We'll learn about generics in the following chapters:
/** A function that takes 0 arguments. */public interface Function0<out R> : Function<R> { /** Invokes the function. */ public operator fun invoke(): R}/** A function that takes 1 argument. */ ...
Read now
Unlock full access