lundi 27 février 2017

What is the most succinct way to use '!=' operator when comparing multiple values to the same variable?

EDIT: I did not mean efficiency as in the program running more efficiently, but I meant it as a quicker way to program the if statement.

I am trying to find a way to reduce my code for efficiency. For example: if(x!=10 && x!=20 && x!=30){} //etc`

I tried this, and I tried multiple other methods:

if(x!=(10 && 20 && 30){}

It does not work. Is there a way to reduce the size of this if statement?

Aucun commentaire:

Enregistrer un commentaire