문제

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