How do you handle huge if-conditions?

后端 未结 21 2279
一向
一向 2021-01-31 17:14

It\'s something that\'s bugged me in every language I\'ve used, I have an if statement but the conditional part has so many checks that I have to split it over multiple lines, u

21条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-31 17:36

    McDowell,

    You are correct that when using the single '&' operator that both sides of the expression evaluate. However, when using the '&&' operator (at least in C#) then the first expression to return false is the last expression evaluated. This makes putting the evaulation before the FOR statement just as good as any other way of doing it.

提交回复
热议问题