Tuples citizenship

kennytm kennytm at gmail.com
Thu Mar 1 14:53:18 PST 2012


bearophile <bearophileHUGS at lycos.com> wrote:
(snip) 
> It's good for tuples to become more common in D code. Some time ago I
> have asked the built-in associative arrays to grow a method to iterate on
> key-value pairs, named "byPair":
> http://d.puremagic.com/issues/show_bug.cgi?id=5466
> 
(snip)
> Bye,
> bearophile

Associative arrays (should) have UFCS, so one could just define

@property auto byPair(AA)(AA aa) {
    return zip(aa.byKey, aa.byValue);
}

in std.array. Or object.di could just define a Pair!(K,V) structure which a
Tuple!(K,V) has an opAssign defined for it.


More information about the Digitalmars-d mailing list