mardi 19 mai 2020

How do I compare multiple values against a single variable? [duplicate]

Is there a shortcut for comparing multiple values such as in the following expression?

if (choice == "a" || choice == "b" || choice == "c") {do something;}

I thought about switch statements, but they only work for single values as far as I know.

And what about variable declaration or constants?

int initialValue = 1, finalValue = 1;

Aucun commentaire:

Enregistrer un commentaire