Clarification in continue statement

Rikki Cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 6 01:43:52 PST 2015


On 6/02/2015 10:37 p.m., Vasileios Anagnostopoulos via 
Digitalmars-d-learn wrote:
>
> hi,
>
> I observed in the documentation
>
> "If continue is followed by /Identifier/, the /Identifier/ must be the
> label of an enclosing while, for, or do loop, and the next iteration of
> that loop is executed. It is an error if there is no such statement."
>
> But there is no example. Can someone provide one example?
>
> I think break also needs a similar example.
>
>
> --
> Dr. Vasileios Anagnostopoulos (MSc,PhD)
> Researcher/Developer
> ICCS/NTUA 9 Heroon Polytechneiou Str., Zografou 15773 Athens,Greece
> T (+30) 2107723404 M (+30) 6936935388
> E vanag at mail.ntua.gr
> <mailto:vanag at mail.ntua.gr><mailto:vanag at mail.ntua.gr
> <mailto:vanag at mail.ntua.gr>> www.ntua.gr
> <http://www.ntua.gr><http://www.ntua.gr/>

void main() {
	import std.stdio : writeln;

	F1: foreach(int i; 0 .. 100) {
		F2: foreach(int j; 0 .. 100) {
			if (j + i > 5)
				continue F1;
			
			writeln("i: ", i, " j: ", j);
		}
	}
}

Example compiled + running with output:
http://dpaste.dzfl.pl/75291aecb07d


More information about the Digitalmars-d-learn mailing list