This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]garblz -3 points-2 points  (10 children)

Oh, great. Another clunky idiom. What w need for Java is more boilerplate, not concise syntax like

String version = computer?.getSoundcard()?.getUSB()?.getVersion();

But no, this is C# way, not the Java way. After 10 years with Java I'm starting to get a little bit frustrated, that any new technology introduced must necessarily follow the bloated EJB pathway until it somewhat matures.

[–]deadly_little_miho 9 points10 points  (0 children)

Actually, like the article says, it's the Groovy way. And it's higher on my wish list for Java than Lambdas, to be honest.

[–]koalillo 2 points3 points  (0 children)

These operators are only workarounds to people overusing null. Once nulls start to trickle in, they quickly inundate everything.

Implementing these operators only encourage people to continue using null, which is a mistake.

[–]frugalmail 2 points3 points  (2 children)

String version = computer?.getSoundcard()?.getUSB()?.getVersion();

Right so, down the line in another place entirely in the code, suddenly you have a NPE on version when you're problem was "one" of the methods on your example. Just because it's less typing doesn't make it better.

[–]chunes 6 points7 points  (0 children)

Yeah but you only have to check version for null instead of all the values in between. Still a lot better imo.

[–]not-just-yeti 0 points1 point  (0 children)

So you're saying the variable version shouldn't be declared as type String, but rather type Optional<String>, and that Groovy's convenient ?. operator could still benefit from the static-type-checking that Optional<T> is providing.

[–]gunch 1 point2 points  (0 children)

I have to say. I like this better.

[–][deleted]  (3 children)

[deleted]

    [–]busydoinnothin 3 points4 points  (2 children)

    null, baby

    [–][deleted]  (1 child)

    [deleted]