Question

I have multiple variables:

  1. var1
  2. var2
  3. var3

How can I check if any of the variables is less than 0, in one single line of code without separating it into 3 if statements?

Était-ce utile?

La solution

It sounds like you mean OR:

if (var1 < 0 || var2 < 0 || var3 < 0) {
    ...
}

Autres conseils

if (var1 < 0 || var2 < 0 || var3 < 0) {
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top