Do you consider this technique “BAD”?

前端 未结 28 1443
借酒劲吻你
借酒劲吻你 2021-02-02 10:57

Sometimes you need to skip execution of part of a method under certain non-critical error conditions. You can use exceptions for that, but exceptions generally are not

28条回答
  •  北荒
    北荒 (楼主)
    2021-02-02 11:49

    You're pretty much just disguising a "goto" as a fake loop. Whether you like gotos or not, you'd be just as far ahead using a real undisguised goto.

    Personally, I'd just write it as

    bool isGood = true;
    
       .... some code
    
       if(isGood)
       {
       .... some more code
       }
    
       if(isGood)
       {
       .... some more code
       }
    

提交回复
热议问题