It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center




已关闭8年。




我已在某处阅读规则:



这句话是真的吗?如果是这样,您能否详细说明为什么我们应该遵守该规则?

最佳答案

我个人不反对提早退房,但我将提议考虑SingerOfTheFall的第三种替代方案。

好处:

  • 正常代码流(即非错误)从顶部干净地流过
    代码
  • 没有机会失败一个“事物”并传递另一个
    “某物”无意中执行了一个代码块
  • 您可以在代码块上强制作用域;包括在范围退出时清理代码
  • 子块中使用的事物

    坏处:
  • 缩进可以累加(尽管可以通过中断来减轻它
    进入子功能)
  • 在您的编辑器中没有大括号匹配,可能很难匹配条件条件错误的错误

  • int foo()
    {
    int errorCode = 0;
    if(!something){
    //100行代码
    if(!something){
    //100行代码
    if(!something){
    //100行代码
    }
    别的 {
    errorCode = -1;
    }
    }
    别的 {
    errorCode = 11;
    }
    }
    别的 {
    errorCode = 1;
    }
    返回errorCode;
    }

    10-08 00:34