| 12-17-2006, 06:30 PM | #1 |
I have a short question. Let's say that I have an if-statement containing and. Will Warcraft stop evaluating the if-statement if it discovers that the first condition is false? Or will it in some cases save processing time to use nestled ifs rather than ands? JASS:// Will FunctionC be evaluated too? if(false and FunctionC()) then |
| 12-17-2006, 06:41 PM | #2 |
erm if (3<2 and 3>4) will also work >_> AND is if two conditions are same, not if they are both true |
| 12-17-2006, 06:48 PM | #3 |
The following expression: JASS:(false and false) I think he is asking something more like this: Once the first operand of an AND operator expression is false, it stops evaluating the next operands included in that expression. JASS:function Test takes nothing returns boolean call BJDebugMsg("TEST!") return true endfunction function RunTest takes nothing returns nothing if (false and Test()) then endif endfunction 'Test' is never evaluated, since after calling RunTest the "TEST!" message is never displayed. |
| 12-17-2006, 06:59 PM | #4 |
Thanks masda70! |
| 12-17-2006, 09:34 PM | #5 |
This is a feature called Short Circuit Boolean Evaluation (or some such) and is useful when certain functions have major problems with incorrect input, eg: if somestring != "" and HaveStoredInteger(cache,"lol",somestring) then //gamecache functions crash if they get an empty string |
