Unable to call each on a lockstep range containing 2 or more ranges
John Colvin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Nov 18 06:17:38 PST 2015
On Wednesday, 18 November 2015 at 14:11:45 UTC, maik klein wrote:
> On Wednesday, 18 November 2015 at 13:51:59 UTC, John Colvin
> wrote:
>> On Wednesday, 18 November 2015 at 12:20:42 UTC, maik klein
>> wrote:
>>> [...]
>>
>> I think this is a bug, please report it at issues.dlang.org
>> and perhaps there will be an explanation or it will be fixed.
>> In the mean time, something like this should work:
>>
>> auto arange2 = zip(ai[],ai1[],ai2[]);
>>
>> arange2.each!((t) => writeln(t[0], t[1], t[2]));
>> // or if you really must have the names:
>> arange2.each!((t) => (a,b,c){ writeln(a, b, c); }(t.expand));
>
> Thanks, but the problem I have with zip is that it doesn't work
> with "ref".
>
>
> for example
>
> auto arange3 = zip(ai[],ai1[],ai2[]);
> foreach(ref a; arange3){
> a[0] = 42;
> }
> Won't change anything. Is this another bug?
Unfortunately, yes: https://issues.dlang.org/show_bug.cgi?id=10541
Note that
while(!arange3.empty)
{
arange3.front[0] = 42;
arange3.popFront();
}
should work as expected.
More information about the Digitalmars-d-learn
mailing list