On Sunday, 27 October 2013 at 14:10:50 UTC, Maurice wrote:
On Sunday, 27 October 2013 at 14:01:31 UTC, Derix wrote:
So, I wanted to wrap my head a little tighter around those
strange animals that are lamdas.
I wrote the simpliest program utilizing a lambda :
import std.stdio;
void main(){
writeln({return "foobar";});
}
You still have to call the lambda just like a function, with ():
import std.stdio;
void main() {
writeln({return "foobar";}());
}
Some clarification:
import std.stdio;
void main() {
auto f = {return "foobar";}; // f behaves like a function.
auto s = f(); // it can be called like any other function, it
takes no parameters.
writeln(s);
}