'AND' vs '&&' as operator

后端 未结 10 604
野性不改
野性不改 2020-11-22 02:42

I have a codebase where developers decided to use AND and OR instead of && and ||.

I know that there is a

10条回答
  •  醉酒成梦
    2020-11-22 03:16

    For safety, I always parenthesise my comparisons and space them out. That way, I don't have to rely on operator precedence:

    if( 
        ((i==0) && (b==2)) 
        || 
        ((c==3) && !(f==5)) 
      )
    

提交回复
热议问题