28

while(freeTime == true) {
if(iHavePlans == true)
waitUntilDone();
/*
* TODO: Fix bug that causes
* coding to call the gaming and
* relaxing methods so often...
*/
code();
}

Comments
  • 11
    Oh... You're one of those "== true" type people, I'm so sorry.
  • 1
  • 1
    Sorry 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 :)
  • 2
    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.
  • 2
    You can try that yourself in most languages (some needs a bit of casting):

    var TestBoolean = 2;

    if (TestBoolean) //true

    if (TestBoolean == true) //false
  • 1
    @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!
  • 2
    @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 😅
Add Comment