bearophile wrote:
KennyTM~:
Make "x in y" returns a bool and works for arrays.
That's something more useful than the sum of usefulness of opDispatch, opPow
and opLength. You use it all the time in code, and in D it's even more useful
than in Python because in D a small linear scan can be very fast. To do that in
my dlibs I use the function isIn(item, items), where items can be an AA too of
course.
Bye,
bearophile
I somewhat agree. For small arrays I find it very useful, I use it all
the time.
compare:
if (x in [1, 2, 3]) { }
if (x == 1 || x == 2 || x == 3) { }
I find the first one prettier. :)