Repost: make foreach(i, a; range) "just work"

Jesse Phillips Jesse.K.Phillips+D at gmail.com
Fri Feb 21 19:51:17 PST 2014


On Thursday, 20 February 2014 at 19:34:17 UTC, w0rp wrote:
>  I suppose the next step after that would be to
> support nested unpacking, but that would require a change in
> syntax so it would be much more complicated.

You mean this?

void main() {
     import std.typecons : tuple;
     import std.range : repeat;
     foreach(k,v1, v2; tuple(1, tuple(2, 3)).repeat(4))
     {}
}

Yeah, that works.


More information about the Digitalmars-d mailing list