I’m a mobile developer, and one of the reasons I switched to Kotlin immediately after it appeared is because of its support of extensions. Extensions allow you to add methods to any existing class, even to Any or an optional type (for example, Int?).

If you extend a base class, all derived classes automatically get this extension. You can also override methods from extensions, which makes this mechanism even more flexible and powerful.

I use Kotlin 1.4.0 for Android in Android Studio 4.0.1. And I assume that all methods will be called from Kotlin, not Java. Even so, most of the extensions will work in other versions of Kotlin, some of them in other environments.

#android #programming #mobile #kotlin

Top 20 Kotlin Extensions for Cleaner Code
3.55 GEEK