Re: lambda syntax with curly braces

2015-08-10 Thread bachmeier via Digitalmars-d-learn
On Monday, 10 August 2015 at 15:05:55 UTC, sigod wrote: I see. But it's really counter intuitive after working with C#. Probably documentation should stress out the difference. Thanks, Adam. I assume you mean this page: http://dlang.org/expression.html There's an Improve this page button

Re: lambda syntax with curly braces

2015-08-10 Thread sigod via Digitalmars-d-learn
On Monday, 10 August 2015 at 16:02:31 UTC, bachmeier wrote: On Monday, 10 August 2015 at 15:05:55 UTC, sigod wrote: I see. But it's really counter intuitive after working with C#. Probably documentation should stress out the difference. Thanks, Adam. I assume you mean this page:

Re: lambda syntax with curly braces

2015-08-10 Thread bachmeier via Digitalmars-d-learn
On Monday, 10 August 2015 at 16:15:40 UTC, sigod wrote: Good point. But I seldom do this because English isn't my native language. Your English looks fine to me. Close enough to native that I can't tell the difference.

Re: lambda syntax with curly braces

2015-08-10 Thread sigod via Digitalmars-d-learn
On Monday, 10 August 2015 at 14:05:30 UTC, Adam D. Ruppe wrote: On Monday, 10 August 2015 at 13:57:50 UTC, sigod wrote: [...] It does exactly what that says: rewrites it to (a) { return { writeln(a); }; } which is returning a delegate. [...] So your code passed a delegate

lambda syntax with curly braces

2015-08-10 Thread sigod via Digitalmars-d-learn
From docs: The following part = AssignExpression is rewritten to FunctionLiteralBody: { return AssignExpression ; } So, I wonder what happens when curly braces already in place? Consider this example: ``` import std.algorithm; import std.stdio; void main() { [1,2,3,4,5] .each!(a

Re: lambda syntax with curly braces

2015-08-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 10 August 2015 at 13:57:50 UTC, sigod wrote: From docs: The following part = AssignExpression is rewritten to FunctionLiteralBody: { return AssignExpression ; } So, I wonder what happens when curly braces already in place? It does exactly what that says: rewrites it to (a) {