Quantcast
Channel: Dafny: An Automatic Program Verifier for Functional Correctness
Viewing all articles
Browse latest Browse all 1106

New Post: do-while loops

$
0
0
Just as in Java, you can use break; (without a label name) if you want to break out of the closest enclosing loop. Unlike in Java, you can also repeat the break keyword in order to break out of some other enclosing loop. For example, if you have an outer loop and an inner loop and want to break out of both loops from inside the inner loop, then you can either label the outer loop and list the label in the break statement:
label Outer:
while ...
{
  ...
  while ...
  {
    ...
    break Outer;
    ...
  }
  ...
}
or you can use a break break; statement, which breaks out of two levels of loops:
while ...
{
  ...
  while ...
  {
    ...
    break break;
    ...
  }
  ...
}
Rustan

Viewing all articles
Browse latest Browse all 1106

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>