And, as you saw, it is error‑prone because you might write = by mistake.Jeff Verdegan wrote: . . . never use == or != with true or false. It's just redundant and adds clutter. . . .
Alex Petsche wrote:Just a quick question to clear up a few things. Does default to true? If so the same is true that defaults to false? It appears so from your post, but I wasn't sure as no one's ever explained this to me.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Alex Petsche wrote:Just a quick question to clear up a few things. Does default to true?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Paul Clapham wrote:One other small comment on that: when you start using descriptive variable names, instead of calling your variables obscure and meaningless things like "x", things become a lot clearer:
fred rosenberger wrote:
You know that these two conditions are mutually exclusive, so you can wrap them into the same if/else block.
I would also suggest you ALWAYS use curly braces, even if they are not needed.
Don't get me started about those stupid light bulbs. |