On 09 Feb, 2012,at 10:57 PM, Andrej Mitrovic <[email protected]> wrote:
On 2/9/12, Jacob Carlborg <[email protected]> wrote:
> Yes it is. Together with delegates.
I didn't find them next to delegates but after hash literals in the
Expressions section.
http://www.d-programming-language.org/_expression_.html#Lambda
Oh, delegates are documented here as well: http://www.dlang.org/function.html
Seems _expression_.html is for the actual delegate literal.
It should have usage examples though. It took me a while to figure out
what was wrong with this:
void test(int function(int, int) func) {
func(1, 2);
}
void main() {
test(x, y => x);
}
Error: undefined identifier x
The fix: test((x, y) => x);
Yeah, parentheses are required if the lambda takes more than one argument.
--
/Jacob Carlborg
_______________________________________________ dmd-beta mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/dmd-beta
