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
-
7Raiden8786ySorry but the "condition == true" is something I can't see xD
Imagine that "condition == true" returns true, do you want to check that value as well? As in "(condition == true) == true", because it's 100% equivalent to what the original statement is :) -
Furthermore, "condition == true" is wrong and can give unintended results.
Boolean is defined as zero for false and everything else than zero for true. But the value "true" is in most languages a simple one or minus one. So if "condition" contains the same integer representation as true, everything works, but if not, than "condition == true" can give out false, even if "condition" is true. -
You can try that yourself in most languages (some needs a bit of casting):
var TestBoolean = 2;
if (TestBoolean) //true
if (TestBoolean == true) //false -
7Raiden8786y@Benedikt very true, in my mind I have strongly typed languages, where a bool is a bool, even if the left hand side is an integer!
-
@hexc @wannabee @7Raiden Was more for clarity, I never check for equality in my code xD plus it was 3 AM... Sheesh guys, can't catch a break around here aye... Plus it doesn't hurt to double check things 😜
@Benedikt For the record, when I wrote it I was writing it in Java, although since it's just a conditional and a loop, it translates to more langs I guess. So the commenters are right, the == true is in fact redundant 😅
Related Rants
-
CowboyBebop21This is my social and Dev life ;(
-
starrynights8925The hardest part of being a programmer wasn't the education, the self-teaching, the sleepless nights or the ho...
-
dronesawake14Why am single 😂😂 On a date with a girl: Her: Tell me what you do for a living Me: I create my own stress...
while(freeTime == true) {
if(iHavePlans == true)
waitUntilDone();
/*
* TODO: Fix bug that causes
* coding to call the gaming and
* relaxing methods so often...
*/
code();
}
rant
my time management needs better management
wip
wk111
still code tho