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.
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.
int a=1;
int b=2;
int add(int a,int b) {
return a+b;
}
int c=add(a,b);
writefln(Result:%d,c);
Nested functions are cool. :-)
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);}
On Thu, 12 Nov 2009 10:21:44 -0500, Don nos...@nospam.com wrote:
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
Steven Schveighoffer:
int c = (){return a + b;}();
You can also write:
int c = {return a + b;}();
Bye,
bearophile
bearophile wrote:
Steven Schveighoffer:
int c = (){return a + b;}();
You can also write:
int c = {return a + b;}();
Bye,
bearophile
Shorter:
int c = a + b;