Mandatory use of braces

前端 未结 21 2322
旧时难觅i
旧时难觅i 2021-02-12 23:26

As part of a code standards document I wrote awhile back, I enforce \"you must always use braces for loops and/or conditional code blocks, even (especially) if they\'re only one

21条回答
  •  梦毁少年i
    2021-02-13 00:15

    I think the important thing about braces is that they very definitely express the intent of the programmer. You should not have to infer intent from indentation.

    That said, I like the single-line returns and continues suggested by Gus. The intent is obvious, and it is cleaner and easier to read.

提交回复
热议问题