سؤال

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