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