5 ms·
Somehow that seems even less readable to me.
by WaxProlix 9y ago
Somehow that seems even less readable to me.
- lenkite 9y agoThis 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 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.
- WaxProlix 9y agoI 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.
- dcow 9y agoSwift also supports trailing closures. It's a concept that's become pretty familiar of late.
- meddlepal 9y agoNever wrote any Groovy? Java developers had no problem picking this style up a decade ago.
- WaxProlix 9y agoNope, 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).
- meddlepal 9y agoI 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.
- dcow 9y agoIt's actually "if the lambda is the last argument in the call you can close the parens after the penultimate argument".