Hacker News new | past | comments | ask | show | jobs | submit login

Somehow that seems even less readable to me.



This is simply "parentheses in a call can be omitted entirely if the lambda is the only argument to that call." This one feature allows for type safe DSL's which eases GUI construction on Android and other domains. https://github.com/Kotlin/anko/wiki/Anko-Layouts

Its also used for chaining stream code which takes in functions. You get used to this feature very quickly.


I know what it is, I'm just saying that in a Java-esque language, omitting parens for function application feels worse than doing so in eg Haskell or even Ruby.


Swift also supports trailing closures. It's a concept that's become pretty familiar of late.


Never wrote any Groovy? Java developers had no problem picking this style up a decade ago.


Nope, never. Just coming back to the JVM ecosystem, actually, as I've been away since around the Java 7 release time (with the exception of some Jython work).


I think you'll be pleasantly surprised how the ecosystem has changed. Legacy code is legacy code, but Java 8 changed a lot and people have mostly also adapted well to ideas coming out of the Scala / Groovy / Kotlin ecosystems primarily because there is just more of it and it's fairly familiar and common to run across libs and projects written those languages now if you're working in Java.


It's actually "if the lambda is the last argument in the call you can close the parens after the penultimate argument".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: