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

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

    if(!value) is clearer and more "elegant", specially if you name boolean variables correctly

    • isWhatever
    • hasWhatever
    • etc

    Something like

    if (Page.IsPostback == true)
    

    seems redundant to me

提交回复
热议问题