in not working for arrays is silly, change my view
Ali Çehreli
acehreli at yahoo.com
Sat Feb 29 21:56:51 UTC 2020
On 2/29/20 11:38 AM, JN wrote:
> assert(1 in [1, 2, 3]);
Because you mentioned canFind, I think you want the semantics to be "is
there an element with this value." If so, it would be confusing to use
the same operator for two different things: For associative arrays, it
means "is there an element accessible with this key."
Unless 'in' works with arrays to mean "is this index valid", then I
don't see the benefit. If we had it, I think more people would ask "why
does 'in' work differently for arrays?"
Are there other languages that support this semantic? Checking... Ok,
Python has it, highly likely because they don't have arrays to begin with.
Ali
More information about the Digitalmars-d-learn
mailing list