Thread overview | |||||
---|---|---|---|---|---|
|
February 06, 2015 Clarification in continue statement | ||||
---|---|---|---|---|
| ||||
Attachments:
| 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@mail.ntua.gr<mailto:vanag@mail.ntua.gr> www.ntua.gr<
http://www.ntua.gr/>
|
February 06, 2015 Re: Clarification in continue statement | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vasileios Anagnostopoulos | 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@mail.ntua.gr > <mailto:vanag@mail.ntua.gr><mailto:vanag@mail.ntua.gr > <mailto:vanag@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 |
February 06, 2015 Re: Clarification in continue statement | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rikki Cattermole | On Friday, 6 February 2015 at 09:43:59 UTC, Rikki Cattermole wrote: > 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. >> > > 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 Would you mind putting in a PR to put some examples into the docs? https://github.com/D-Programming-Language/dlang.org/edit/master/statement.dd |
Copyright © 1999-2021 by the D Language Foundation