Safe Navigation Operator “?.” for D2 ?

Dicebot public at dicebot.lv
Fri Feb 28 03:11:26 PST 2014


On Friday, 28 February 2014 at 09:24:23 UTC, John Colvin wrote:
>> Chaining . operation is a code smell to begin with
>
> It is? Why?

If a system is well-designed, then "null" state either means 
something (and needs to be explicitly handled) or is not possible.

?. provides simple and easy way to write a sloppy code that does 
not tell the reader if resulting code flow for null case was 
intentional. Also it is very easy to get accustomed to use ?. 
everywhere instead of . and get broken logic instead of 
NullPointerException for cases when pointer is wrongly assumed to 
never be null.


More information about the Digitalmars-d mailing list