anonymous function/deleget usage

Don nospam at nospam.com
Thu Nov 12 07:21:44 PST 2009


Sam Hu wrote:
> How can I reach something like below code:
> 
> int a=1;
> int b=2;
> int c=(int a,int b){
>    return a+b;}
> writefln("Result:%d",c);
> 
> Thanks in advance.

You need to call the delegate you've made.

int a=1;
int b=2;
int c=(int a,int b){
    return a+b;}(a,b);
writefln("Result:%d",c);}


More information about the Digitalmars-d-learn mailing list