I am currently working with some legacy code that has this if statement:
if(c == 30 || c == 3 || c == 4 || r == 'Y' || t == 'X' ||( s>= 50000 && s <= 50999))
{
//do nothing
}
else
{
function1();
}
I am trying to eliminate the unnecessary "do nothing" by negating the if, but I'm not sure what to do about the 's' part:
if((c != 30 && c != 3 && c != 4 && r != 'Y' && t != 'X') ...what goes here?...)
{
function1();
}
I've tried both && (s >= 50000 || s <= 50999) and ||(s < 50000 && s > 50999) but those failed the test cases I ran. When I tried &&( s < 50000 || s > 50999)) all my test cases succeeded, but I know I can't test for everything and so I'm hoping someone with a stronger grasp of logical negation can tell me with certainty whether this is correct.
Aucun commentaire:
Enregistrer un commentaire