.byKeyValue should probably return a Tuple

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 15 21:20:32 PST 2017


On Thu, Feb 16, 2017 at 05:02:41AM +0000, Yuxuan Shui via Digitalmars-d wrote:
> On Wednesday, 15 February 2017 at 22:02:01 UTC, Seb wrote:
> > On Wednesday, 15 February 2017 at 21:54:20 UTC, Yuxuan Shui wrote:
> > > for(k, v; aa) { ... } is better than:
> > > 
> > > for(o; aa) {
> > >     auto k = o.key, v = o.value;
> > >     ...
> > > }
> > > 
> > > right?
> > > 
> > > Are there any reason why .byKeyValue doesn't return a Tuple?
> > 
> > There's byPair (http://dlang.org/phobos/std_array.html#byPair) that as a
> > library does exactly the following:
> > 
> > ```
> > a.byKeyValue.map!(pair => tuple(pair.key, pair.value))
> > ```
> 
> Thanks!
> 
> It should be more visible though. Can we include it here:
> https://dlang.org/spec/hash-map.html ?

Please file a bug against dlang.org to request this doc update, so that
people won't forget to do it.  Thanks!


T

-- 
It's amazing how careful choice of punctuation can leave you hanging:


More information about the Digitalmars-d mailing list