Iterating over the tupleof of a struct

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 23 10:21:27 PDT 2014


On Saturday, 23 August 2014 at 01:56:06 UTC, Dicebot wrote:
> 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) { }

Yeah, I got confused as I expected

	foreach (val1, val2; test.tupleof)
	{
		//...
	}

To destructure the result of test.tupleof, but I just got an 
iteration variable instead.


More information about the Digitalmars-d-learn mailing list