lundi 25 juin 2018

Why can't the compiler warn against this programming error?

If I write the following code:

int a = 5;
if (a == 1 || a == 1) {
   // do something
}

Why can't the compiler point out that the second part of the if statement is unnecessary, or warn that the programmer has likely made a mistake?

Aucun commentaire:

Enregistrer un commentaire