Key and value with ranges
Andrey Zherikov
andrey.zherikov at gmail.com
Tue Oct 3 20:22:30 UTC 2023
On Tuesday, 3 October 2023 at 19:57:06 UTC, christian.koestlin
wrote:
> On Tuesday, 3 October 2023 at 01:55:43 UTC, Andrey Zherikov
> wrote:
>> On Monday, 2 October 2023 at 18:46:14 UTC, christian.koestlin
>> wrote:
>>> [...]
>>
>> Slightly improved:
>> ```d
>> import std;
>>
>> [...]
>
> Thanks .. the thing with ref result is very clever!
> Should `ref result` be `return result`?
`ref` might not be necessary fo AA but I'm not sure.
`fold` requires function to return something (see
[doc](https://dlang.org/phobos/std_algorithm_iteration.html#fold)):
> for each element x in range, result = fun(result, x) gets
> evaluated.
More information about the Digitalmars-d-learn
mailing list