Is there any reason why in can't work with dynamic arrays?
Brett
Brett at gmail.com
Thu Sep 19 04:23:06 UTC 2019
On Wednesday, 18 September 2019 at 10:25:57 UTC, Alex wrote:
> On Tuesday, 17 September 2019 at 18:10:40 UTC, Brett wrote:
>>> I like to just check if y >= 0 && y < x.length which is more
>>> clear anyway.
>>
>>
>> Yes, I could see that, but it doesn't do that with AA's so but
>> I could see how it could be problematic.
>>
>> Alternatively, have a keys for a DA:
>>
>> then one can do
>>
>> if (y in x.keys)
>>
>> and this is far more expressive so there is no confusion and
>> also works with AA's(and would not result in keys having to be
>> created because it is semantically the same as (y in x) if x
>> is an AA).
>
> It is also expressive to define
> size_t y;
> and to check y only for being < x.length.
>
> An array does not have keys. It has indices.
That is called parsing language to be pedantic with out loss of
generality. It means nothing. A rose by any name is a rose. In
fact, it means one understands less of the problem than they
think.
More information about the Digitalmars-d
mailing list