in not working for arrays is silly, change my view

JN 666total at
Mon Mar 2 11:39:26 UTC 2020

On Saturday, 29 February 2020 at 21:56:51 UTC, Ali Çehreli wrote:
> 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."

Does it? I always viewed it as "is this value in list of keys"

> 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.

Well, Python lists are for most purposes equivalent to arrays and 
it hasn't really been confusing for people.

More information about the Digitalmars-d-learn mailing list