Java Coding standard / best practices - naming convention for break/continue labels

前端 未结 10 2340
难免孤独
难免孤独 2020-12-15 05:36

Sometimes a labeled break or continue can make code a lot more readable.

OUTERLOOP: for ( ;/*stuff*/; ) {
    //...lots of code

    if ( isEnough() ) break         


        
10条回答
  •  伪装坚强ぢ
    2020-12-15 06:23

    They are kind of the goto of Java - not sure if C# has them. I have never used them in practice, I can't think of a case where avoiding them wouldn't result in much more readable code.

    But if you have to- I think all caps is ok. Most people won't use labelled breaks, so when they see the code, the caps will jump out at them and will force them to realise what is going on.

提交回复
热议问题