In this article, we’ll discuss a common mistake beginners make when switching from Java to Kotlin for the first time. I often notice that people who have recently switched from Java to Kotlin become fascinated by its idiomaticity and start using it where they shouldn’t.
For example:
.
What’s wrong here?
There is also a logical error here, that has been made due to the difficulty of perceiving this construction — there is no check that “tags” is not empty.
You don’t need StringUtils either, Kotlin has isBlank() for strings.
How can you fix it?