Which option is faster...
David
d at dav1d.de
Mon Aug 5 08:21:25 PDT 2013
Am 05.08.2013 15:59, schrieb jicman:
>
> Greetings!
>
> I have this code,
>
> foreach (...)
> {
>
> if (std.string.tolower(fext[0]) == "doc" ||
> std.string.tolower(fext[0]) == "docx" ||
> std.string.tolower(fext[0]) == "xls" ||
> std.string.tolower(fext[0]) == "xlsx" ||
> std.string.tolower(fext[0]) == "ppt" ||
> std.string.tolower(fext[0]) == "pptx")
> continue;
> }
>
That's how I would do it.
if(["doc", "docx", "xls", "xlsx", "ppt", "pptx"].canFind(fext[0].toLower) {
continue;
}
With the array beeing a runtime/compiletime constant with a sensible
name. WORD_EXTENSIONS or something.
More information about the Digitalmars-d-learn
mailing list