GENERATE/PREV.gifGENERATE/NEXT.gif

Short-Circuiting Logical Expressions

Following the convention in most other programming languages, logical expressions in MAXScript are short-circuiting or non-strict. This means that only enough of the sub-expression is evaluated to determine the overall result:

This saves execution time and enables useful shorthand notation. For example, if you want to use the value of the variable 'a' and then calculate 'sin a', but only if 'a' isn’t undefined, then you could use the example below, in which 'sin a' wouldn't be evaluated if 'a' were indeed undefined:

if a != undefined and sin a > 0 then ...

In a strict language, the 'sin a' evaluation of an undefined operand would result in an error and you would need to break up the expression into two if statements.