Вопрос

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?

Это было полезно?

Решение

It sounds like you mean OR:

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

Другие советы

if (var1 < 0 || var2 < 0 || var3 < 0) {
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top