August 2017
Intermediate to advanced
440 pages
10h
English
Sometimes we need to use function type parameters from inline functions not directly in the function body, but in another execution context, such as a local object or a nested function. But standard function type parameters of inline functions are not allowed to be used this way because they allow non-local returns, which should not be allowed if this function could be used inside another execution context. To inform the compiler that non-local returns are not allowed, this parameter must be annotated as crossinline. Then it will act like a substitution that we are expecting in an inline function, even when it is used inside another lambda expression:
fun boo(f: () -> Unit) { //... } inline fun foo(crossinline f: () ...Read now
Unlock full access