What is the difference between 'assignment' and 'equality' operators

In MAXScript, there is a VERY BIG difference between these two operators!

The '=' is the so-called assignment operator and is used to assign the result of the expression on the right side of the operator to the variable on the left side.

The '==' is the so-called equality comparison operator and is used to check whether the two expressions on both sides are equal or not. It returns true of they are equal, and false if they are not.

It is a common error to mistype '==' as '=' which can lead to errors in IF comparisons, non-initialized variables etc.

In the following example, the variable a is set to 1. In the IF expression, 'a' should be compared to 0, but it is assigned by mistake the value 0 instead. The result of the expression is not a boolean value (true or false) and an error message is generated to inform you about the problem:

TYPICAL ERROR:

   a = 1
   if a = 0 then print "A is Zero!" else print "A is not Zero!"
   -- Type error: if-test requires BooleanClass, got: 0

CORRET CODE:

   a = 1
   if a == 0 then print "A is Zero!" else print "A is not Zero!"
   -->"A is not Zero!"

In the second version, the variable 'a' is set to 1. In the IF expression, 'a' is correctly compared to 0. The result of the expression is a boolean value (false) and the expected result is printed.