DEV Community

Discussion on: A small piece of code which is going to inspire you to try out Kotlin

Collapse
 
nurettin profile image
Nurettin Onur TUĞCU • Edited

Actually, the java example is better, since the lambda is lazily evaluated. putIfAbsent will always try to construct it's second argument even if it isn't in the map. However, that doesn't mean you can't use it in kotlin as well.