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

后端 未结 19 2753
爱一瞬间的悲伤
爱一瞬间的悲伤 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:44

    I am also of the opinion that using == inside an if is redundant and I have another suggestion, at least visually, by introducing spaces:

    if ( ! created)
    

    Even using OpenDyslexic as font, the not sign ! next to the opening bracket ( can be too close to distinguish it at a glance if(!created).

提交回复
热议问题