foreach loop

wobbles via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 3 06:51:33 PST 2015


On Tuesday, 3 November 2015 at 14:47:14 UTC, Namal wrote:
> Hello guys,
>
> I remember it is possible to get the index for each element in 
> the foreach loop, but I forgot how to do it. Can you help me 
> out please. Thx.

auto arr = ["Hello", "World"];

foreach(int idx, string str; arr){
    writefln("%s = %s", idx, str);
}


More information about the Digitalmars-d-learn mailing list