This site requires JavaScript, please enable it in your browser!
Greenfoot back
Mux
Mux wrote ...

2012/12/1

short question to if()

Mux Mux

2012/12/1

#
what does the argument: a and b are true or false if( a && b) means both must be true if(a || b) means one must be true right?? I got a loop like this: if( y >= 0 && y<getHeight()) { } with y < 0.
Gevater_Tod4711 Gevater_Tod4711

2012/12/1

#
yes && means both must be true and || means one must be true.
actinium actinium

2012/12/1

#
Also i think if y>= 0 is false in the && expression the rest of the expression is not evaluated because the expression cannot be true. Also i think in an || expression if the first expression evaluates true then the second expression does not need evaluating. || and && employ the shortcut once the expression can be evaluated.
Mux Mux

2012/12/1

#
thanks got it
You need to login to post a reply.