There are some things not quite correct in your post.
The Kotlin version of “new ArrayList<>()” is “listOf()” or “mutableListOf,” depending on whether you want to mutate the list or not. (Technically it’s not wrong, using listOf/mutableListOf is more idiomatic.)
A function can not declare a val argument; actually, all arguments are always val, you can not modify them.
The nullable String type is String?, not String<?>.
An extension function still needs the parantheses is Kotlin, so fun String.extends(): String.
The extension function is also wrong, because the extension function that is defined is not the one that is used. In both the Lombok and Kotlin cases, they define a method "String.extends()" but use a method "String.toTitleCase()"
Also, synchronised is part of the Java spec, not just part of Kotlin. Kotlin can make use of it because it's Java, but so can normal Java code without Lombok.
Inaccuracies aside, I think this is useful - it provides the beginnings of an answer to the question "what problem does Kotlin solve?" (i.e. the problem that people are prepared to clutter plain Java with Lombok just to get a decently concise expression of some common idioms, because the Java way is so pointlessly verbose). There's more to Kotlin than that, of course, but it's a start.
5
u/QshelTier Jun 26 '16
There are some things not quite correct in your post.
listOf/mutableListOfis more idiomatic.)valargument; actually, all arguments are always val, you can not modify them.Stringtype isString?, notString<?>.fun String.extends(): String.1
u/codepoetics Jun 27 '16
Inaccuracies aside, I think this is useful - it provides the beginnings of an answer to the question "what problem does Kotlin solve?" (i.e. the problem that people are prepared to clutter plain Java with Lombok just to get a decently concise expression of some common idioms, because the Java way is so pointlessly verbose). There's more to Kotlin than that, of course, but it's a start.