[OT] C# 6.0 ?. null propagation operator

Ali Çehreli via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 20 15:26:52 PDT 2015


On 04/20/2015 03:18 PM, rumbu wrote:
> On Monday, 20 April 2015 at 21:22:53 UTC, deadalnix wrote:
>> On Monday, 20 April 2015 at 20:09:59 UTC, rumbu wrote:
> ..
>>>
>>>
>>> I fail to understand Atila example. Just to be sure:
>>>
>>> C#:
>>> var roleName = userManager.CurrentUser?.GetRole()?.Name;
>>>
>>> D (Jakob):
>>> auto roleName = userManager.getOrNull!("CurrentUser", "GetRole",
>>> "Name");
>>>
>>> D (Atila):
>>> auto roleName = ?
>>
>> These API look overly complex. Why not simply:
>>
>> maybe(userManager).CurrentUser.GetRole().Name ?
>>
>> Also, CAPITAL LETTER ARE THE BEST !
>
> Because CurrentUser, GetRole() and Name can also return null in this
> scenario.
>

The solution linked elsewhere in this thread solves that issue as well:

 
http://forum.dlang.org/thread/lnsc0c$1sip$1@digitalmars.com?page=6#post-mailman.2584.1403213951.2907.digitalmars-d:40puremagic.com

Ali



More information about the Digitalmars-d mailing list