duplicates - How to avoid while-loop code duplication? -


    string s = console.readline();     while( s!= null)     {          //           //   ....          s = console.readline();      } 

the code above input, verify it, process , input again, obviously, s = console.readline(); code duplication.

what tricks there avoid duplication?

in python (where there no do-while loop guaranteed @ least 1 iteration), trick use infinite loop explicit break.

while( true )  // or whatever evaluates true unconditionally {     s = console.readline();     if (s == null) {         break;     }     // } 

Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -