August 2017
Intermediate to advanced
440 pages
10h
English
Until now, we've only seen definitions of function types where only the types were specified, but not parameter names. Parameter names have been specified in function literals:
fun setOnItemClickListener(listener: (Int, View, View)->Unit) {
// code
}
setOnItemClickListener { position, view, parent -> /* ... */ }
The problem comes when the parameters are not self-explanatory, and the developer does not know what the parameters mean. With SAMs there were suggestions, while in the function type defined in the previous example, they are not really helpful:

The solution is to define function types with named ...
Read now
Unlock full access