On Sunday, 11 August 2019 at 16:11:15 UTC, DanielG wrote:
int[][] whatever = [
    [0],
    [0, 1, 2],
    [5, 6, 7, 8, 9, 10]
];
writeln(whatever[2]);                    // [5, 6, 7, 8, 9, 10]
writeln(typeid(whatever[2]));            // int[]
auto x = whatever[2].filter(x => x > 7); // error

Error: template std.algorithm.iteration.filter cannot deduce function from argument types !()(int[], void), candidates are: ...

Online example:
https://run.dlang.io/is/LUXFuF

...

I'm guessing I need to give the compiler some help understanding that this is an array of ints, but 1) how, and 2) why? [if typeid() seems to understand just fine?]

You're missing an exclamation mark after filter - it takes the predicate as a template argument. This compiles just fine:

    auto x = whatever[2].filter!(x => x > 7);

--
  Simen

Reply via email to