• Continue to a higher-up loop
    10 replies, posted
Is there a way to make continue stop the current cycle but instead of going to the next one of this loop, go to the next one of a loop situated higher up (they're nested)?
Going to need the code here, I have no idea what you are trying to do.
A break stops the current loop in all programming languages I know.
[QUOTE=ZeekyHBomb;26201994]A break stops the current loop in all programming languages I know.[/QUOTE] This. I actually only rarely have had an use for continue, moreso for break.
[QUOTE=ZeekyHBomb;26201994]A break stops the current loop in all programming languages I know.[/QUOTE] That's not what I need. There are a few loops inbetween the current one and the one i need to continue.
Depending on the language, there might be an instruction such as break n; to break out of n loops. Another possibility is a boolean, that is checked in each loop to decide whether it too should break and reset when the outer loop is reached, or a goto, to just jump to the outer loop.
[QUOTE=ZeekyHBomb;26202359][b]Depending on the language, there might be an instruction such as break n; to break out of n loops.[/b] Another possibility is a boolean, that is checked in each loop to decide whether it too should break and reset when the outer loop is reached, or a goto, to just jump to the outer loop.[/QUOTE] Is there actually a language which has this, I remember it being discussed in a thread here ages ago but I don't think we ever found a language with it.
[url=http://php.net/manual/en/control-structures.break.php]PHP[/url] [editline]21st November 2010[/editline] [url=http://www.tutorialspoint.com/unix/unix-loop-control.htm]UNIX shell[/url] [editline]21st November 2010[/editline] [url=http://www.purebasic.com/documentation/reference/break_continue.html]PureBasic[/url] I'll stop searching now..
I remember reading something about break and labels, you use it like a goto :label, but insted it's break:label, :label being put at the beginning of the loop you want to break. Let me dig that a little.
I know D and Java have that.
[url]http://www.python.org/dev/peps/pep-3136/[/url] [url]http://mail.python.org/pipermail/python-3000/2007-July/008663.html[/url] beeeep
Sorry, you need to Log In to post a reply to this thread.