e.g.: import std.stdio; void callit(void delegate() dg) { // call delegate with context pointer dg(); } void main() { int x;auto dg = ()=>writeln(++x); // create a delegate using a lambda functioncallit(dg); callit(dg); callit(dg); callit(dg); }
Forgot to say, the output here would be: 1 2 3 4 -Steve
