Iterating over the tupleof of a struct

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 22 18:56:04 PDT 2014


On Saturday, 23 August 2014 at 01:32:13 UTC, Meta wrote:
> On Saturday, 23 August 2014 at 01:24:10 UTC, Meta wrote:
>> What is happening here? Are these two extra ulongs the offsets 
>> of the fields in the struct?
>
> And I just realized that that's obviously not the case. It's 
> just an iteration variable. Problem solved.

It is same with arrays:

int[] arr = [ 1, 2, 3 ];

// ok, iterates elements
foreach (elem; arr) { }

// also ok, iterates elements + counts current index
foreach (index, elem; arr) { }


More information about the Digitalmars-d-learn mailing list