After starting my work on Kotlin, I realized that this language will change my life, and you know what? I was totally right. Here is my list of five less known things about Kotlin and I hope you will find at least three worth knowing.
Name your imports
In Kotlin, imports are used by the compiler to let you name your classes by their unqualified name.
Change companion object name
Companion object was introduced to replace static members. It is not only for declaring static properties but also to name them.
I bet you used function references before but have you ever tried to use them to compose functions? Imagine that you want to map an array of prices to prices that are taxed, discounted and rounded.
Change name of generated class
Extension functions are one of the most attractive features in Kotlin but using them in Java code can give you a serious headache. It is ugly and besides is nothing else like invoking a static method.
Validate an assignment and “veto” it
The way in which Kotlin handles delegation is pretty spectacular so if you are not familiar with it, you should totally check my article: “Zero boilerplate delegation in Kotlin”.
Full article here>>: 5 cool things you probably don’t know about Kotlin