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?

Was it helpful?

Solution

It sounds like you mean OR:

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

OTHER TIPS

if (var1 < 0 || var2 < 0 || var3 < 0) {
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top