News for hackers. Stuff that matters.
Re:Ask HN: Your favorite syntactic sugar from any language? by vorg on Saturday June 16, 2018 @07:48AM (#17327042)
> groovys's safe navigation operator a?.getB()?.getC()

Apache Groovy also has shortcut property syntax so you can write `a?.b?.c` to get the same effect. Of course, all the syntactic sugar mixed together becomes quite confusing quite quickly. Some Groovers want to write the `?` once only and have it ripple through so you'd only need write `a?.b.c` in Groovy 3. But then, what if you actually want an NPE if `getB()` works but `getC()` doesn't? Perhaps `a?.b¿.c` would do the trick!

There are no comments on this comment yet.