O'Reilly logo
  • santiago4 thinks this is interesting:

Listing 2.25 Importing Extension Functions

import com.example.time.plusDays

Note that the function name directly follows the package name because the extension does not reside inside a class or object. If there are multiple extension functions with the name plusDays defined in the package, all of them are imported.


Extension functions offer a convenient way to work around limitations of third-party APIs that you cannot modify directly. For example, you can add methods to interfaces or encapsulate boilerplate around APIs. This is highly ...


Cover of Kotlin for Android App Development, First Edition