Powered by Kotlin
Kotlin as a programming language has provided a lot of syntactic support for engineers to concisely express the intent of their code. Moreover, some of the features allow engineers to separate concerns and organize the code to be more manageable.
Extension functions
Kotlin extension functions allow adding extra functionalities to an existing class without modifying its source code. This feature is useful and even mandatory for the following use cases:
- Add more functions to a class from an external library, or a final class. For example, we want to extract the first letter of each word and join them by a dot, so
Sam Payne
would becomeS.P
. The Kotlin String does not provide a function for this, so we can write an extension function instead:fun String.getFirstLetters(): String = split(" ").joinToString(".") { it.first().toString() }
- Enhance...