'in' for arrays?
Bill Baxter
dnewsgroup at billbaxter.com
Tue Dec 5 21:09:54 PST 2006
I keep wanting to say
if (val in somearray) {
}
but 'in' doesn't work for arrays... Is there any reason why not?
Basically I just expect it to do something like this function (untested,
modified from a similar function in Cashew):
T* item_in (T) (T[] haystack, T cmp)
{
foreach (index, inout needle; haystack) {
if (needle==cmp) {
return &needle;
}
}
return null;
}
I.e. I just expect it to do a plain old linear search through the list,
nothing fancy, but it would be handy.
--bb
More information about the Digitalmars-d
mailing list