Originally posted by NickFitz
View Post
Oh boy...that's just messed...
So basically we first test if the variable is true.
If the variable is true we then test if the variable is false. If the variable is both true and false we return false, otherwise, if the variable is both true and true, we return true.
If the variable is false we then test if the variable is false. If the variable is both false and false we return false. If the variable is false and not false we return true.
There are two parts of that line which are unreachable in standard boolean logic. For the first false to be reached test has to show as true for the first == and false for the second. For the second true test has to show as false for the first == and true for the second.
I am in awe of the messed-up-ness of this code. Not only is it unnecessarily complex, but half of it is unreachable and the other half performs the same test twice (making sure?). It's a trifecta of bad code design!
So basically we first test if the variable is true.
If the variable is true we then test if the variable is false. If the variable is both true and false we return false, otherwise, if the variable is both true and true, we return true.
If the variable is false we then test if the variable is false. If the variable is both false and false we return false. If the variable is false and not false we return true.
There are two parts of that line which are unreachable in standard boolean logic. For the first false to be reached test has to show as true for the first == and false for the second. For the second true test has to show as false for the first == and true for the second.
I am in awe of the messed-up-ness of this code. Not only is it unnecessarily complex, but half of it is unreachable and the other half performs the same test twice (making sure?). It's a trifecta of bad code design!


Leave a comment: