Is there any reason why in can't work with dynamic arrays?
Adam D. Ruppe
destructionator at gmail.com
Tue Sep 17 17:46:09 UTC 2019
On Tuesday, 17 September 2019 at 17:43:39 UTC, Brett wrote:
> T[] x;
>
> if (y in x) ...
>
> It just checks to see if y is in between 0 and length.
Most people asking for this want it to check that the *value* y
is in the array x, which is rejected for requiring a linear
search.
But your idea could be done quickly, just I expect it would cause
confusion with the people asking for the other.
I like to just check if y >= 0 && y < x.length which is more
clear anyway.
More information about the Digitalmars-d
mailing list