Which is clearer form: if(!value) or if(flag == value)?

后端 未结 19 2620
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 19:07

I understand this is a subjective question, so I apologize if it needs to be closed, but I feel like it comes up often enough for me to wonder if there is a general preferen

19条回答
  •  醉梦人生
    2020-12-23 19:51

    If the condition is just a check of a single value, then !value is quicker.

    However, when the condition contains multiple value checks, I find it much easier to read value == false. Somehow it is easier to parse multiple checks for equality than multiple negations of values.

提交回复
热议问题