Language Reference - Operators

Home

Operators are the symbols that you use to manipulate data items. eg In the expression A = B + C, the + operator acts on the data items B and C. The data items B and C are the operands. One of the unique features of the method language is its flexibility concerning the use of operators. You may apply an operator to any data item without regard to its type. If the operand is not the correct type, Equinox will automatically convert it. Consider the following:

Similarly for subtract, multiply and divide. The string concatenation operator combines two strings:

The following table describes all of the operators that you can use. For each, the table includes the associated syntax convention, the returned value and the "priority" of the operator.

OperatorSyntaxReturned valuePriority
[ ]X[Y]Yth character in string X1
( )(X)Enclosed expression2
(Unary Minus)- XNegative value of X3
(Unary plus)+ XPositive value of X3
BinaryNotBinaryNot XOne's complement of X3
BinaryAndX BinaryAnd YContains bits which are 1 if both the matching bits in X and Y are 14
BinaryOrX BinaryOr YContains bits which are 1 if either of the matching bits in X and Y are 15
BianryXorX BinaryXor YContains bits which are 1 if the bits in X and Y are different5
^X ^ YX to power of Y6
RootX Root YY Root of X6
*X * YX multiplied by Y7
/X / YX divided by Y7
DivX Div YInteger result of X divided by Y7
ModX Mod YRemainder of X divided by Y7
+X + YSum of X and Y8
-X - YDifference of X and Y8
&X & YX concatenated with Y9
ToX To YSee following notes10
(List Expression)-See following notes11
(comma)X, YSee following notes12
>>X >> YTrue is string X exists in string Y13
<<X << YPerforms a reverse search in string Y returning True if string X exists in string Y13
<X < YTrue if X is less than Y13
ExistsInX ExistsIn YTrue is string X exists in string Y13
ContainsX Contains YTrue is string Y is contained in string X13
<=X <= YTrue if X is less the or equal to Y13
=X = YTrue if X is equal to Y13
<>X <> YTrue if X is not equal to Y13
>=X >= YTrue is X is greater than or equal to Y13
>X > YTrue if X i greater than Y13
NotNot XTrue if X is False14
AndX And YTrue if X and Y are both True15
OrX Or YTrue if either X or Y is True16
XorX Xor YTrue if either X or Y is True (not both)16

If an expression contains more than one operator, the order in which they are actioned is determined by their priorities. The smaller the priority number, the higher priority the operator takes. Operators with equal priority are actioned in the order in which they occur within the expression. eg Consider the following general expression:

A + B + 4 * C

The * operator is of a higher priority than +. C is multiplied by 4, A is added and then B.