On 2015-02-07 at 13:47, Kadir Erdem Demir wrote:

     auto sum = aArr.reduce!((a,b) => a.count + b.count);

The line above gives

C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(770): Error: cannot 
implicitly convert expression (__lambda3(result, front(_param_1))) of type int 
to A
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(791): Error: template 
instance app.main.reduce!((a, b) => a.count + b.count).reduce!(A, A[]) error 
instantiating
source\app.d(363):        instantiated from here: reduce!(A[])


    // auto sum = aArr.reduce!((a,b) => a.count + b.count); // Wrong

    auto sum = reduce!((a, b) => a + b.count)(0, aArr);     // Good


See here: http://dlang.org/phobos/std_algorithm.html#.reduce

Reply via email to