delegates and functions

SrMordred patric.dexheimer at gmail.com
Sun Jun 10 17:58:45 UTC 2018


> 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




More information about the Digitalmars-d-learn mailing list