Programming-Idioms

History of Idiom 78 > diff from v40 to v41

Edit summary for version 41 :
[Cpp] why so much indentation - better

Version 40

2016-02-17, 13:40:08

Version 41

2016-02-18, 16:58:01

Idiom #78 "do while" loop

Execute a block once, then execute it again as long as boolean condition c is true.

Idiom #78 "do while" loop

Execute a block once, then execute it again as long as boolean condition c is true.

Code
for{
   someThing()
   …
   someOtherThing()
   if !c {
     break
   }
}
Code
for{
   someThing()
   …
   someOtherThing()
   if !c {
     break
   }
}
Comments bubble
Go has no do while loop, use the for loop, instead.
Comments bubble
Go has no do while loop, use the for loop, instead.
Doc URL
https://golang.org/ref/spec#For_statements
Doc URL
https://golang.org/ref/spec#For_statements
Demo URL
http://play.golang.org/p/aNVIjY8oVK
Demo URL
http://play.golang.org/p/aNVIjY8oVK
Code
do {
  someThing();
  someOtherThing();
} while(c);
Code
do {
  someThing();
  someOtherThing();
} while(c);
Comments bubble
The block code is not repeated in the source.
Comments bubble
The block code is not repeated in the source.