Foreach problem

Tim M a at b.com
Sat Jan 10 18:33:27 PST 2009


Why is this an error. Dmd wants to make sure that I declare a new variable  
in the foreach statement and not use an existing one?

module test;

void main()
{
	int i;
	int[] nums;
	foreach(i; nums)
	{
		//
	}
}


dmd test.d

test.d(7): Error: shadowing declaration test.main.i is deprecated


More information about the Digitalmars-d-learn mailing list