We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm having a problem writing my code. I wanted to execute a statement when more than one expression is true
boolean checking(){
boolean myVar = false;
boolean[] each = new boolean [8];
for (int i = 0; i < 8; i++){
if(i > 0){ //just a random expression
each[i] = true;
}
}
if(each[0] && each[1] && each[2] && each[3] && each[4] && each[5] && each[6] && each[7]){ //i need a better way to write that since the elements aren't always going to be 8 elements
myVar = true;
}
return myVar;
}
this is a boolean function example (not the whole code)
Answers
thank you! it worked but i didn't get it, can't understand what
:
means in thefor
loop i guess i'll have to look that up, thanks!http://Processing.org/reference/for.html
thank you, and the way you've put
return false;
if an element is false solves the problem i had in the beginning so thanks very much!Just to make things clearer between
for ( : )
&for ( ;; )
loops, check it out checkAllTrue() w/ those 2 approaches together for easier comparison: :Dyeah I found out yesterday, it wasn't as hard as I thought. Thanks though :)