associative arrays: iteration is finally here

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Wed Oct 28 10:38:14 PDT 2009


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



More information about the Digitalmars-d mailing list