Java Reference
In-Depth Information
Operators
WMLScript defines a complete set of operators that are very similar to languages such as C
and Java. These operators are as follows:
Assignment Operators = , += , -= , *= , /= , div= , %= , &= , |= , ^= , <<= , >>= , and >>>= .
Arithmetic Operators + , - , * , / , div , and % .
Bitwise Operators << , >> , >>> , & , ^ , | , and ~ .
Logical Operators && , || , and ! .
Equality Testing Operators == , != , > , >= , < , and <= .
The comma operator is used to perform multiple computations or evaluations within a single
statement. This operator might seem a bit odd because the value of a statement is the value of
the left operand. In other words, in this statement
x = y=0, z+5;
the net result is that y will be set equal to zero and x will be set equal to z+5 . Basically, use of
the comma operator enables you to eliminate one or more lines of code, but at the risk of code
obfuscation. It is generally recommended that the comma operator be avoided.
The final operator, typeof , is used to evaluate a variable's data type. The output of the typeof
operator is an integer value correlating to one of the following data types: Integer (0), Float
(1), String (2), Boolean (3), and Invalid (4).
Statements
Like all high-level programming languages, WMLScript includes complete capabilities for
controlling the flow of code. These capabilities include conditional statements, loops, and
breaks.
24
The simplest conditional statement is the if statement. If the situation calls for it, the else
clause is also provided. If the conditional statements are more than one line in length, braces
( {} ) should surround them:
if (some_condition)
{
statement1;
statement2;
}
else
{
other_statement1;
other_statement2;
}
 
Search WWH ::




Custom Search