Re: Confusion with anonymous functions and method overloads

2016-05-21 Thread ag0aep6g via Digitalmars-d-learn
On 05/21/2016 04:39 PM, pineapple wrote: But I don't understand why. Could someone clarify the difference between the two? Common mistake, because other languages (e.g. C#) use similar but different syntax. The `foo => bar` syntax doesn't use braces. When you add braces around bar, that's

Re: Confusion with anonymous functions and method overloads

2016-05-21 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 21 May 2016 at 14:39:59 UTC, pineapple wrote: void clean(in void delegate(in T value) func){ this.clean((in T values[]) => { foreach(value; values) func(value); }); This doesn't do what you think it does. It passes a lambda that *returns* that

Confusion with anonymous functions and method overloads

2016-05-21 Thread pineapple via Digitalmars-d-learn
I wrote a pair of methods that looked like this: void clean(in void delegate(in T value) func){ this.clean((in T values[]) => { foreach(value; values) func(value); }); } void clean(in void delegate(in T values[]) func){ ... } I was getting a