digitalmars.D.learn - No aa.byKey.length?
- Yuxuan Shui (3/3) Apr 01 2016 Why?
- =?UTF-8?Q?Ali_=c3=87ehreli?= (4/7) Apr 01 2016 Sounds easy to implement. Please file an enhancement request:
- Ozan (2/5) Apr 02 2016 aa.keys.length
- Jonathan M Davis via Digitalmars-d-learn (10/16) Apr 02 2016 That allocates an array. Doing that would be like doing
- John Colvin (3/23) Apr 03 2016 Maybe
- Jonathan M Davis via Digitalmars-d-learn (3/29) Apr 03 2016 Yeah, that's a clever workaround.
- Yuxuan Shui (2/13) Apr 03 2016 So should we not add length to byKey?
- Jonathan M Davis via Digitalmars-d-learn (5/20) Apr 04 2016 I don't see any reason for the result of byKey to not have length. It's ...
- John Colvin (3/18) Apr 04 2016 Yes. But until that happens, my workaround allows you to carry on
Why? This is annoying when I need to feed it into a function that requires hasLength.
Apr 01 2016
On 04/01/2016 01:50 PM, Yuxuan Shui wrote:Why? This is annoying when I need to feed it into a function that requires hasLength.Sounds easy to implement. Please file an enhancement request: https://issues.dlang.org/ Ali
Apr 01 2016
On Friday, 1 April 2016 at 20:50:32 UTC, Yuxuan Shui wrote:Why? This is annoying when I need to feed it into a function that requires hasLength.aa.keys.length
Apr 02 2016
On Saturday, April 02, 2016 15:38:30 Ozan via Digitalmars-d-learn wrote:On Friday, 1 April 2016 at 20:50:32 UTC, Yuxuan Shui wrote:That allocates an array. Doing that would be like doing aa.byKeys().array().length. And associate arrays already have length. You can do auto len = aa.length; The problem is when you want to operate on a range, and the function that you want to pass it to wants length on the range. If byKeys returned a range with length, then that would work, but since it doesn't, it doesn't. Having other ways to get the length doesn't help. - Jonathan M DavisWhy? This is annoying when I need to feed it into a function that requires hasLength.aa.keys.length
Apr 02 2016
On Saturday, 2 April 2016 at 16:00:51 UTC, Jonathan M Davis wrote:On Saturday, April 02, 2016 15:38:30 Ozan via Digitalmars-d-learn wrote:Maybe aa.byKey().takeExactly(aa.length)On Friday, 1 April 2016 at 20:50:32 UTC, Yuxuan Shui wrote:That allocates an array. Doing that would be like doing aa.byKeys().array().length. And associate arrays already have length. You can do auto len = aa.length; The problem is when you want to operate on a range, and the function that you want to pass it to wants length on the range. If byKeys returned a range with length, then that would work, but since it doesn't, it doesn't. Having other ways to get the length doesn't help. - Jonathan M DavisWhy? This is annoying when I need to feed it into a function that requires hasLength.aa.keys.length
Apr 03 2016
On Sunday, April 03, 2016 23:46:10 John Colvin via Digitalmars-d-learn wrote:On Saturday, 2 April 2016 at 16:00:51 UTC, Jonathan M Davis wrote:Yeah, that's a clever workaround. - Jonathan M DavisOn Saturday, April 02, 2016 15:38:30 Ozan via Digitalmars-d-learn wrote:Maybe aa.byKey().takeExactly(aa.length)On Friday, 1 April 2016 at 20:50:32 UTC, Yuxuan Shui wrote:That allocates an array. Doing that would be like doing aa.byKeys().array().length. And associate arrays already have length. You can do auto len = aa.length; The problem is when you want to operate on a range, and the function that you want to pass it to wants length on the range. If byKeys returned a range with length, then that would work, but since it doesn't, it doesn't. Having other ways to get the length doesn't help.Why? This is annoying when I need to feed it into a function that requires hasLength.aa.keys.length
Apr 03 2016
On Monday, 4 April 2016 at 00:50:27 UTC, Jonathan M Davis wrote:On Sunday, April 03, 2016 23:46:10 John Colvin via Digitalmars-d-learn wrote:So should we not add length to byKey?On Saturday, 2 April 2016 at 16:00:51 UTC, Jonathan M Davis wrote:Yeah, that's a clever workaround. - Jonathan M Davis[...]Maybe aa.byKey().takeExactly(aa.length)
Apr 03 2016
On Monday, April 04, 2016 02:32:56 Yuxuan Shui via Digitalmars-d-learn wrote:On Monday, 4 April 2016 at 00:50:27 UTC, Jonathan M Davis wrote:I don't see any reason for the result of byKey to not have length. It's just that given that it doesn't currently have length, John's suggestion provides a way to turn it into a range with length. - Jonathan M DavisOn Sunday, April 03, 2016 23:46:10 John Colvin via Digitalmars-d-learn wrote:So should we not add length to byKey?On Saturday, 2 April 2016 at 16:00:51 UTC, Jonathan M Davis wrote:Yeah, that's a clever workaround.[...]Maybe aa.byKey().takeExactly(aa.length)
Apr 04 2016
On Monday, 4 April 2016 at 02:32:56 UTC, Yuxuan Shui wrote:On Monday, 4 April 2016 at 00:50:27 UTC, Jonathan M Davis wrote:Yes. But until that happens, my workaround allows you to carry on getting work done :)On Sunday, April 03, 2016 23:46:10 John Colvin via Digitalmars-d-learn wrote:So should we not add length to byKey?On Saturday, 2 April 2016 at 16:00:51 UTC, Jonathan M Davis wrote:Yeah, that's a clever workaround. - Jonathan M Davis[...]Maybe aa.byKey().takeExactly(aa.length)
Apr 04 2016