DLang Tour : Functions as arguments

Tony tonytdominguez at aol.com
Thu Dec 28 01:37:16 UTC 2017


On this page:
https://tour.dlang.org/tour/en/basics/delegates

there is:
--------------------------------------------------------
void doSomething(int function(int, int) doer) {
     // call passed function
     doer(5,5);
}

doSomething(add); // use global function `add` here
                   // add must have 2 int parameters

--------------------------------------------------------

I can't get it to compile unless it is:

doSomething(&add);




More information about the Digitalmars-d-learn mailing list