in not working for arrays is silly, change my view

Steven Schveighoffer schveiguy at gmail.com
Mon Mar 2 15:50:08 UTC 2020


On 3/2/20 6:39 AM, JN wrote:
> 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"

Array keys are the element index..

So essentially:

int[int] c1;
int[] c2 = new int[4];
c1[3] = 10;
c2[3] = 10;

assert(3 in c1); // true
assert(3 in c2); // what should this do?

-Steve


More information about the Digitalmars-d-learn mailing list