Adding the ?. null verification

Yota via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 24 09:52:30 PDT 2014


On Sunday, 22 June 2014 at 08:15:45 UTC, Andrei Alexandrescu 
wrote:
> On 6/21/14, 3:38 PM, H. S. Teoh via Digitalmars-d wrote:
>> On Sat, Jun 21, 2014 at 03:26:45PM -0700, Andrei Alexandrescu 
>> via Digitalmars-d wrote:
>>> On 6/19/14, 1:29 PM, Etienne wrote:
>>>> writeln(currAssignment.safeDeref.typeInfo.ident.or("meh"));
>>>
>>> "or" is really nice and terse. I think we should add that to 
>>> std.
>>> safeDeref isn't the best choice of name.
>> [...]
>>
>> What's your suggestion?
>
> That we add "or" to std and find a name for safeDeref that 
> doesn't use the word "safe" in a confusing manner. -- Andrei

C# calls the ?? operator the "null-coalescing" operator.  I have 
absolutely no idea why, but that does give precedence for calling 
it "coalesce".  Then again, who wants to memorize how that's 
spelled?  They also have "GetValueOrDefault()" on Nullable<>, but 
that is kinda long.  How about just "orDefault" or "ifNull"?


More information about the Digitalmars-d mailing list