Is while (true) with break bad programming practice?

后端 未结 22 2271
-上瘾入骨i
-上瘾入骨i 2020-11-27 04:38

I often use this code pattern:

while(true) {

    //do something

    if() {
        break;
    }

}   

Another progr

22条回答
  •  -上瘾入骨i
    2020-11-27 05:00

    I prefer the while(!) approach because it more clearly and immediately conveys the intent of the loop.

提交回复
热议问题