Foreach on a template?

Robin Allen r.a3 at ntlworld.com
Tue Mar 6 09:28:56 PST 2007


You can define an opApply in a template and use it like this:

mytemplate!(int).opApply(int delegate(int v) {

	...loop...
	return 0;
});

Which is what I had to do since D won't let you do this:

foreach(v; mytemplate!(int))
{
	...loop...
}

The second one looks much nicer, and they both mean the same thing. So 
why do we have to use the first?

-Rob



More information about the Digitalmars-d mailing list