Revamping associative arrays

Walter Bright newshound1 at digitalmars.com
Sun Oct 18 00:59:04 PDT 2009


bearophile wrote:
> I'd really like the "default" iteration on an AA to yield its keys,
> instead of values as currently done. Because if I have a key I can
> find its value, while the opposite is not possible, so having keys is
> much more useful. This is true in Python too. In my dlibs all
> iterables and functions behave like this. The current D design is
> just a design mistake ad Walter was wrong on this.

You can iterate over both keys and values with:

     foreach (key, value; aa)



More information about the Digitalmars-d mailing list