Safe Navigation Operator “?.” for D2 ?
Steven Schveighoffer
schveiguy at yahoo.com
Thu Feb 27 13:45:11 PST 2014
On Thu, 27 Feb 2014 16:20:47 -0500, Peter Alexander
<peter.alexander.au at gmail.com> wrote:
> On Thursday, 27 February 2014 at 20:49:59 UTC, deadalnix wrote:
>> On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote:
>>>
>>> Apparently C# will get it in the next version.
>>> http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx
>>>
>>> What do you think how well would this work in D2 ?
>>
>> Chaining . operation is a code smell to begin with, and having
>> everything nullable is dubious as well. This is fixing a problem
>> that shouldn't exists to begin with.
>
> +1
>
> Please no.
Yes. Taken from the example:
parent?.child?.child?.child
Given no context, this may make sense. But with context, likely you have
verified beforehand the answers to some, if not all, of these question
marks.
However, even with that, I can't help but expect there should be a way to
do this in D without changing the language.
Something like:
ifnull(parent).child.child.child
-Steve
More information about the Digitalmars-d
mailing list