Explicit and implicit typing
 
 
 

Explicit typing

Normally MEL figures out whether a number is an integer or a float based on whether it has a decimal part. You can force a number to be an integer or float by declaring its type explicitly:

(float) 7
// The number is floating point.
(int) 7.5
// The number is integer (MEL automatically truncates to 7)

You can also explicitly state that a value is a string, even if it doesn’t exactly look like one:

(string) 500
// This is the same as "500"
(string) 56.56
// This is the same as "56.56"

Implicit type conversion

Maya automatically converts numbers to strings or vice versa when you use them together and it’s obvious what you meant.

Be careful: some cases are ambiguous, and what MEL chooses to do may not be what you meant. For example:

print("500" + 5);

Prints: 5005 (the string "500” with the string “5” added on the end), not 505 (the number 500 plus 5).