Post Reply 
Checking conditions [IF ... THEN ... ELSE] performance
09-14-2015, 09:01 PM (This post was last modified: 09-14-2015 09:02 PM by komame.)
Post: #4
RE: Checking conditions [IF ... THEN ... ELSE] performance
Generaly each condition has two parts: before the operator and after the operator.

In the case of the OR operator the first part is always checked and if it returns True the second part should be skipped.
In the case of the AND operator the first part is always checked and if it returns False the second part should be skipped.

Code:
local a=1,b=2,c=3,d=4;

IF a==1 OR (b==2 AND c==4 OR d==4)  // the first part is [a==1] and the second part is the [(b==2 AND c==4 OR d==4)]
the first part returns True so all after the OR operator should be skipped.

IF a==2 AND (b==2 AND c==4 OR d==4)  // the first part is [a==2] and the second part is the [(b==2 AND c==4 OR d==4)]
the first part returns False so all after the AND operator should be skipped.

I believe that all programming languages are working that way.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Checking conditions [IF ... THEN ... ELSE] performance - komame - 09-14-2015 09:01 PM



User(s) browsing this thread: