Search code examples
arraysd

How to intersect to array in D?


I need to find difference between two arrays of strings in D. The problem, that I can't understand how to use SetDifference from std.algorithm.

    auto x = SetDifference(filearr1,filearr2);

get error:

Error: struct std.algorithm.SetDifference cannot deduce function from argument types !()(string[], string[]), candidates are:


Solution

  • Use setDifference with a lower-case "s".

    SetDifference is the name of the type that's returned by setDifference, which happens to be a template struct. The compiler cannot automatically determine template arguments from structs, only from function calls, which is why for most of those template structs a helper function exists.