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 compile error on the second line of that example:

E:\Dropbox\Projects\d\mach\misc\refcounter.d(63): Error: none of the overloads of 'clean' are callable using argument types (void delegate() @system delegate(const(uint[]) values) pure nothrow @safe), candidates are: E:\Dropbox\Projects\d\mach\misc\refcounter.d(62): mach.misc.refcounter.RefCounter!uint.RefCounter.clean(const(void delegate(const(uint))) func) E:\Dropbox\Projects\d\mach\misc\refcounter.d(67): mach.misc.refcounter.RefCounter!uint.RefCounter.clean(const(void delegate(const(uint[]))) func) E:\Dropbox\Projects\d\mach\misc\refcounter.d(109): Error: template instance mach.misc.refcounter.RefCounter!uint error instantiating

When I got rid of the "=>" and changed the first method to this, it compiled without issue:

    void clean(in void delegate(in T value) func){
        this.clean((in T values[]){
            foreach(value; values) func(value);
        });
    }

But I don't understand why. Could someone clarify the difference between the two?

Thanks!

Reply via email to