Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I've been programming for years and I still do this. For me, it indicates that the value you're testing is specifically boolean. Since any non-zero value also evaluates to true, you can improve readability by doing this.
-
devmg1049yThis may seem silly but I try to avoid if-statements. Often there is actually no need to use them, as you can index into tables or make function calls instead. If you do that you can cache results and only recompute values when necessary. If you are not computing values, then you are instead relying on side effects, and although there are times when it's necessary, I've found that most often there is a better way to get efficient and simple code. You just need some library to manage the constructs you need for such data flow. -
I work with elastic search (Java full text search engine) and they always do this:
if(someBool == false) { ...
I havent seen a single ! so far. I don't know why this annoys me so much -
devmg1049yIf in javascript, "if (x === true)" is very useful, and has a different meaning than "if (x)", i.e. "if (x == true)" -
ggromx4319yI only came here wondering how many statements would it require to terminate a life, but the comments became so relevant in terms of different scenarios in which it may be relevant.
I really enjoy this community, always sharing knowledge. -
devios156269y@devmg In JavaScript if (x) is not the same as if (x == true). Consider x = "test". It's truthy, but not == true.
Related Rants

Boolean Logic....
Project manager logic.
How do you even come up with shit like this?
Everytime I see
if (x.getSomeBoolean() == true) ...
I die a little bit inside.
undefined
butwhy
logic
booleans