Polymorphism

As in mathematical expressions, MAXScript operators are polymorphic. This term means a single operator can be used to operate on a number of different types of values and performs the appropriate action for each type of value.

For example, a "+" operator between two integers performs integer arithmetic, between two floats it performs real arithmetic, and between two matrices it performs a matrix addition.

MAXScript allows certain non-mathematical types to use certain math operators. You can concatenate two strings with the "+" operator,

For example

"twas brillig" + " and the slithy tobes"

x.name += sequence_number as string

In some cases, you can mix operand types and MAXScript converts them appropriately. For example, adding a float to an integer results in a float. Multiplying a 3D point by a float results in a scalar vector product, and so on.

Internally in MAXScript the allowable operators and the actions performed by the operators are defined for each type of value. The allowable operators and their actions are documented with the value type descriptions.

See also

Inheritance and Polymorphism