It's jumble post time! Today's theme: ifs, booleans, and stuff like that.
Let's start off with Mark Glennon, who stumbled across one of the more complex ways of testing that a number is not zero ...
bool validateCheckAmount(float checkAmt) { bool retVal = false; if (checkAmt == 0) { retVal = retVal || false; } else { retVal = retVal || true; } return retVal; }
Then there's William, who's coworker always insisted on taking the scenic route to variable assignment ...
if ( BitCount != 8 ) expectedBits = 8; else expectedBits = BitCount;
There is some hope though; Brian Boccia's coworker was able to speed up variable assignment without requiring an else block ...
if( nextIndex != currIndex )
{
nextIndex = currIndex;
}
Now I'm not sure if this really falls under "bools" or "ifs" ... but no less, here is a rather strange "error handling" block that James D. discovered ...
if (errorval == NO_ERROR) { nextProcessCode = "continue"; } else { // show the error currentUserId = currentUserId; //remove this line }
Deb Edb noticed that some of the coders at an ISO-9001-certified company he worked at had a certain sweet spot for Schrödinger's ...
if ( (actionFlag == 0) && (actionFlag == 1) )
{
// ...
}
And I suppose I'll wrap it up with the yin to the last example's yang, this bit from Steve, who's coworker wanted to make sure all of his bases were covered ...
if (connectionOpen || !connectionOpen)
{
...
}