On Tuesday, 20 August 2013 at 16:51:35 UTC, Jonathan M Davis wrote:
On Tuesday, August 20, 2013 17:58:19 Byron wrote:
I am trying to use startsWith with an array of needles. Failes
with not being able to match any functions. Not sure if there is
a work around.

const auto ignore = [".git/", ".gitignore"];

foreach(DirEntry e; getcwd.dirEntries(SpanMode.depth).filter!(a
=> !a.name.startsWith(ignore))) {
writeln(e.name);
}

startsWith dosen't take an array of needles. It takes a variadic list of them.
So, it needs to be something more like

!a.name.startsWith(".git/", ".gitignore")

If you want to save the list though, you can use std.typetuple.TypeTuple and
an alias:

alias TypeTuple!(".git/", ".gitignore") ignore;

At that point, the rest of your code should work as-is.

- Jonathan M Davis

What if I want to load my ignore list from a file?

Reply via email to