Now that you know about WMLScript’s datatypes, it’s time to see how they can be linked with operators to form expressions.
If you know such languages as C or Java, the operators in this section will be familiar to you. Some of them have subtle differences, however, which are usually linked to WMLScript’s dynamic typing. These differences will be pointed out as we encounter them.
Appendix C lists all the operators and summarizes their behaviors. If you know C or Java syntax, you may want to skip this chapter and check back only for the operators you’re not familiar with. It’s probably worth reading the next section, however, since this explains how the datatype conversion rules from Chapter 10, apply to operators.
operators can take values of more
than one type. For example, the
* operator for
multiplication can operate on either integers or floating-point
numbers. WMLScript also defines which conversions are done in these
Operators that always take the same type of operands simply convert
the arguments to those types. If the conversion fails, the result of
the operation is
Operators that take operands of any type simply use the values as they are. No conversion is performed because none is needed.
As you see from these rules, there can be unexpected gotchas: sometimes things don’t do what you expect. If you’re not sure of the type of a value at a particular time, it’s worth using standard library ...