[OT] C# 6.0 ?. null propagation operator

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 20 16:06:19 PDT 2015


On Monday, 20 April 2015 at 22:18:31 UTC, 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.

No, they all return a maybe, that is the nature of maybe monad.


More information about the Digitalmars-d mailing list