[OT] C# 6.0 ?. null propagation operator

rumbu via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 20 15:18:30 PDT 2015


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.



More information about the Digitalmars-d mailing list