A few months ago I’ve started to discover Jetbrains’ Kotlin language which gave a good impression to me. I can’t express my thoughts better than this comment
Kotlin isn’t revolutionary but that’s what is nice about it. If you want revolution then there is Scala and all its headaches. If you want a language that basically codifies Effective Java then that’s Kotlin. — meddlepal@reddit
There is a bunch of excellent tutorial on the web, and I don’t want to bore you with the basics, I just simply want to show you through an example that besides the highlighted sentence Kotlin is less verbose than Java.
So given a string as key, and a list of integers as value. Add a value to the key’s list if its exits, otherwise create the list first, then add the value for it.
Java version
Kotlin version
So don’t hesitate it absolutely worth a try 🙂
原文链接:A small piece of code which is going to inspire you to try out Kotlin
暂无评论内容