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
 komame Member Posts: 50 Joined: Aug 2015
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.
 « Next Oldest | Next Newest »

 Messages In This Thread Checking conditions [IF ... THEN ... ELSE] performance - komame - 09-14-2015, 06:24 PM RE: Checking conditions [IF ... THEN ... ELSE] performance - Joe Horn - 09-14-2015, 07:21 PM RE: Checking conditions [IF ... THEN ... ELSE] performance - Tim Wessman - 09-14-2015, 07:36 PM RE: Checking conditions [IF ... THEN ... ELSE] performance - komame - 09-14-2015 09:01 PM RE: Checking conditions [IF ... THEN ... ELSE] performance - primer - 09-14-2015, 09:24 PM RE: Checking conditions [IF ... THEN ... ELSE] performance - Joe Horn - 09-15-2015, 05:04 AM RE: Checking conditions [IF ... THEN ... ELSE] performance - roadrunner - 09-14-2015, 10:06 PM RE: Checking conditions [IF ... THEN ... ELSE] performance - cyrille de brĂ©bisson - 09-15-2015, 05:25 AM RE: Checking conditions [IF ... THEN ... ELSE] performance - StephenG1CMZ - 09-15-2015, 09:42 AM

User(s) browsing this thread: 1 Guest(s)