Best language features in Kotlin (for me)

I have been doing Java and Scala for many years. Recently my team switched to Kotlin and everybody is enjoying it so far. In this blog post I want to share a personal selection of language features that I really like.

Smart casts on polymorphic collections


Kotlin has a super concise and safe way to narrow down a polymorphic list to a specific sub-type using the as? syntax.



Logging return values


There are situations, where we want to log the return value of a function before actually returning it. Usually, this is done by storing the return value into a variable, doing the log statement and finally returning that variable. Kotlin makes this is a bit simpler with the .also keyword for side-effects. Using .also, we don't have to introduce this artificial variable.



... more to come