On Saturday, 4 August 2012 at 15:23:39 UTC, Russel Winder wrote:
[...]
I can do:
[...]
auto f() { return delegate () { writeln("Hello World."); }; }
          auto t = new Thread(f);
[...]
However:
[...]
auto t = new Thread( delegate () { return delegate () { writeln("Hello World."); }; } ) ;
[doesn't work]

You need parentheses to call the anonymous delegate:
auto t = new Thread( delegate () { return delegate () {
writeln("Hello World."); }; }()) ;

You don't need them with f, because there you have to write &f to
refer to the delegate itself. (And because you don't use
-property.)

Reply via email to