Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
February 15, 2017 .byKeyValue should probably return a Tuple | ||||
---|---|---|---|---|
| ||||
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? |
February 15, 2017 Re: .byKeyValue should probably return a Tuple | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuxuan Shui | 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)) ``` |
February 16, 2017 Re: .byKeyValue should probably return a Tuple | ||||
---|---|---|---|---|
| ||||
Posted in reply to Seb | 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 ? |
February 15, 2017 Re: .byKeyValue should probably return a Tuple | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuxuan Shui | 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: |
February 16, 2017 Re: .byKeyValue should probably return a Tuple | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On Thursday, 16 February 2017 at 05:20:32 UTC, H. S. Teoh wrote: > 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: >> > > [...] >> > >> > 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 Or just do it yourself - it's not that difficult: https://github.com/dlang/dlang.org/edit/master/spec/hash-map.dd |
February 17, 2017 Re: .byKeyValue should probably return a Tuple | ||||
---|---|---|---|---|
| ||||
Posted in reply to Seb | On Thu, Feb 16, 2017 at 08:43:57AM +0000, Seb via Digitalmars-d wrote: > On Thursday, 16 February 2017 at 05:20:32 UTC, H. S. Teoh wrote: > > 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: [...] > > > > 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 > > Or just do it yourself - it's not that difficult: > > https://github.com/dlang/dlang.org/edit/master/spec/hash-map.dd Well, I didn't have time to fix it then, and I almost forgot about it. But luckily I kept this thread alive in my mail reader, so here it is: https://github.com/dlang/dlang.org/pull/1573 T -- People say I'm indecisive, but I'm not sure about that. -- YHL, CONLANG |
Copyright © 1999-2021 by the D Language Foundation