What if....

J. Landman Gay jacque at hyperactivesw.com
Sun Jan 27 14:27:55 EST 2013

On 1/27/13 12:39 PM, Peter Haworth wrote:
> Musings about complex if statements on this Sunday morning....
> Lets say you have a complex if statement with 4 conditions that must all be
> true.  Is there any advantage, other than personal preference/style, to:
> if cond1 and cond2 and cond3 and cond4 then.....
> or
> if cond1 then
>     if cond2 then
>        if cond3 then
>           if cond4 then...
> In either case, as soon as a condition evaluates to false, none of the rest
> are evaluated, right?

Right, both examples are equivalent. In the single line version (example 
1) the conditions are evaluated left to right, and as soon as one is 
false the rest are abandoned.

Parentheses indicate which conditions are part of a grouping but don't 
influence the direction of evaluation.

Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com

More information about the use-livecode mailing list