Good practice : compare a value with a boolean?

Posted by NLemay on Stack Overflow See other posts from Stack Overflow or by NLemay
Published on 2012-09-11T21:33:22Z Indexed on 2012/09/11 21:38 UTC
Read the original article Hit count: 216

Filed under:
|

Most of the time, I prefer to write this :

if(isWelcome() == true){}
if(isWelcome() == false){}

instead of this

if(isWelcome()){}
if(!isWelcome()){}

Because I feel that it is easier to read (but I do understand that it doesn't make sense).

I would like to know if there is a common agreement about this practice. What most developer do? And I'm wondering if the compiler is doing the extra comparaison, or if it understand that it is useless.

© Stack Overflow or respective owner

Related posts about if-statement

Related posts about boolean