I have so many of these in my code:
if ( x1 == x2 && y1 == y2) {
// do nothing
}
else {
// do the thing
}
I wonder if I can replace it with just if, without else, to make the code cleaner. I tried the following:
if ( x1 != x2 && y1 != y2) {
// do the thing
}
but it doesn't work because if only one of them is not equal, then the whole thing is false.
Aucun commentaire:
Enregistrer un commentaire