October 2019
Intermediate to advanced
434 pages
11h 54m
English
One way in which we can control the performance of our higher-order functions is through the usage of the inline modifier keyword. The inline modifier allows us to improve the performance of our higher-order functions by indicating to the compiler that the implementation of a function can be inlined at the call site, thereby avoiding the performance overhead associated with variable capture and class instantiation of a higher-order function.
To explore how this works, let's start by defining this function, safelyRun:
fun safelyRun(action: () -> Unit) { try { action() } catch (error: Throwable) { println("Caught error: ${error.message}") }}
This is a top-level, higher-order function that will run whatever lambda is passed ...
Read now
Unlock full access