associative arrays: iteration is finally here
Pelle Månsson
pelle.mansson at gmail.com
Wed Oct 28 12:47:06 PDT 2009
Lars T. Kyllingstad wrote:
> Pelle Månsson wrote:
>> Andrei Alexandrescu wrote:
>>> Pelle Månsson wrote:
>>>> Also, foreach with a single variable should default to keys, in my
>>>> opinion.
>>>
>>> That is debatable as it would make the same code do different things
>>> for e.g. vectors and sparse vectors.
>>>
>>>
>>> Andrei
>>
>> Debatable indeed, but I find myself using either just the keys or the
>> keys and values together, rarely just the values. Maybe that's just me.
>
>
> I've used iteration over values more often than iteration over keys.
>
> Besides, I think consistency is important. Since the default for an
> ordinary array is to iterate over the values, it should be the same for
> associative arrays.
>
> -Lars
I don't understand this, when do you want the values without the keys?
If you do, shouldn't you be using a regular array?
Actually, it doesn't matter all that much, as long as we get .keys and
.values as alternatives.
More information about the Digitalmars-d
mailing list