delegates and functions
drug
drug2004 at bk.ru
Sun Jun 10 22:36:27 UTC 2018
On 10.06.2018 20:58, SrMordred wrote:
>> a => { return 2*a; }
>> /\ \ /
>> || \ /
>> || \ /
>> || \ /
>> || \ /
>> This is \ /
>> function \ This is definition of delegate
>> definition \
>>
>> so you have a function that returns delegate.
>>
>> ```
>> it's like
>> a => a => 2*a;
>> or
>> (a){ return () { return 2*a; }
>
> I believe that a lot of other languages work differently, so when their
> knowledge are transposed to D, people get confused at first.
>
> Eg. in JS:
>
> x = x => x * 2;
> x = x =>{ return x * 2; }
> //equivalent
>
>
Ah, I see. From this point of view there is some inconsistency indeed.
More information about the Digitalmars-d-learn
mailing list