Just in case you do not fully understand what I just said, let me give you some examples of what I meant:
1 == 2; is false
2 ==2; is true
Using and and or makes this a little bit more complicated. For && the statement is true iff both sides of the equation are true while for || the statement is true if ether side of the equation is true. I will give you some examples:
true && true; is true
true && false; is false
false && false; is false
true || true; is true
true || false; is true
false || false; is false
We can use both && and || in the same expression. If we do this, we need to know that you evaluate && before ||, but if something is in parentheses, you do that first. Here are some examples:
true && true || false; is true
false && true || false && false; is false
(true || false) && (false || false); is false
false || true && (false || true); is true
These can get infinity complex, but here are some helpful shortcuts to telling if something will be true or false:
1) true || (stuff) is always true
2) false && (stuff) is always false
Hopefully you learned a thing or two about booleans, and please comment if you have any further questions.
PS- This Saturday, I went to a Quiz Bowl tournament and our team won! Go LASA!
PS- This Saturday, I went to a Quiz Bowl tournament and our team won! Go LASA!
No comments:
Post a Comment