.byKeyValue should probably return a Tuple

Yuxuan Shui via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 15 21:02:41 PST 2017


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 ?


More information about the Digitalmars-d mailing list