How do you handle huge if-conditions?

后端 未结 21 1737
一向
一向 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:40

    I resort to separate boolean values:

    Bool cond1 == (var1 && var2);
    Bool cond2 == (var3 && var4);
    
    if ( cond1 && cond2 ) {}
    

提交回复
热议问题