Programming-Idioms

History of Idiom 78 > diff from v36 to v37

Edit summary for version 37 :
[Go] Added a note has to why we have to use the for loop.

Version 36

2016-01-01, 20:20:41

Version 37

2016-01-01, 20:21:37

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.
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