[dmd-beta] D2 2.058 beta
Jacob Carlborg
doob at me.com
Fri Feb 10 02:04:15 PST 2012
On 09 Feb, 2012,at 10:57 PM, Andrej Mitrovic <andrej.mitrovich at gmailcom> wrote:
> On 2/9/12, Jacob Carlborg <doob at me.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20120210/c0ad7ef8/attachment.html>
More information about the dmd-beta
mailing list