Best refactoring for the dreaded While (True) loop

前端 未结 12 958
感动是毒
感动是毒 2021-02-04 10:27

If, like me, you shiver at the site of a While (True) loop, then you too must have thought long and hard about the best way to refactor it away. I\'ve seen several different im

12条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-04 10:53

    My preference would be

    start:
    
       // code goes here
    
    goto start;
    

    This most clearly expresses the intent. Good luck getting it past your coding standards. (Wonder how much karma this is going to cost me).

提交回复
热议问题