I know this is going to seem like an unforgiveable sin, but I have 150 variables, and I want to create an if function that does the following:
if(a != 0 && b != 0 && c != 0....) { //do this} else { //do this instead}
However, when I set one of the if statement conditions (i.e b!=1
), whilst the others are still the same (a!=0
, c!=0
), the else function is still run, even though it should be the initial //do this
instead of the //do this instead
(see code snippet above).
My question is:
1. Is there a reason why it is not working, and if there is, how do i fix it?
2. Is there a simpler way to do that without having to list all 150 variables !=0 && !=0
etc..?
Cheers