Timeline for Why is it bad to use redundancy with logical operators? [duplicate]
Current License: CC BY-SA 3.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 3, 2014 at 19:01 | comment | added | user40980 | See also Make a big deal out of == true? | |
Feb 3, 2014 at 17:33 | history | closed |
user7043 gnat Kilian Foth user40980 amon |
Duplicate of Why Use !boolean_variable Over boolean_variable == false | |
Jan 31, 2014 at 19:09 | comment | added | James Snell |
No, I'm saying that there are too many "programmers" who don't understand basic type safety, get their types mixed up and test for !anInt with unexpected results...
|
|
Jan 31, 2014 at 13:35 | comment | added | Bart van Ingen Schenau |
@JamesSnell: Would you really recommend (anInt == 0) == true ? I agree that for numeric results you should have an explicit test. What I said is that if you require explicit tests for operations that result in a boolean value, then you should apply that exact same logic to the result of operator== .
|
|
Jan 31, 2014 at 11:19 | comment | added | James Snell |
@BartvanIngenSchenau - depends on if some half-wit is mixing up bools with other value types like int or not...
|
|
Jan 31, 2014 at 8:55 | review | Close votes | |||
Feb 3, 2014 at 17:33 | |||||
Jan 31, 2014 at 8:01 | comment | added | Bart van Ingen Schenau |
As operator== yields a boolean value itself, your followup question should be: "Don't you think writing (bBool == true) == true makes the code even more straightforward to understand? Why don't you use that style?".
|
|
Jan 31, 2014 at 3:21 | answer | added | Thiago Silva | timeline score: 2 | |
Jan 31, 2014 at 3:16 | answer | added | user71548 | timeline score: 1 | |
Jan 31, 2014 at 2:48 | answer | added | DougM | timeline score: 0 | |
Jan 31, 2014 at 2:47 | answer | added | U2EF1 | timeline score: 1 | |
Jan 31, 2014 at 2:45 | answer | added | Loren Pechtel | timeline score: 2 | |
Jan 31, 2014 at 2:42 | review | First posts | |||
Jan 31, 2014 at 3:35 | |||||
Jan 31, 2014 at 2:25 | history | asked | RodeoClown | CC BY-SA 3.0 |