logoalt Hacker News

accrualyesterday at 10:59 PM1 replyview on HN

> I don't think it is normal to follow the flow assuming nothing has happened.

I think it is for situations where the programmer wants to check a child property but the parent object may be null. If the parent is expected to be null sometimes, the syntax lets the programmer express "try to get this value, but if we can't then move on" without the boilerplate of explicitly checking null (which may be a better pattern in some cases).

It's sort of like saying:

- Get the value if you can, else move on. We know it might not be there and it's not a big deal.

v.s.

- The value may not be there, explicitly check and handle it because it should not be null.


Replies

BoiledCabbagetoday at 12:27 AM

Your summary is almost correct but replace where you used "get" with "set".