Priority 2 operators

.x.yDot operator
++x++Postfix ++ operator
--x--Postfix -- operator

They are unary postfix operators and have left-associativity.


Table of contents:


Dot operator

Postfix ++ operator

Postfix -- operator

Dot operator

The dot operator calls a member of the operand.

This operator call a member of the instance that is returned by the left expression of the operator. The member is specified by the right expression of the operator.


int i = new int(10); // 10

string str = i.ToString(); // "10"


The i of the int is instructed to call the ToString() method.

Postfix ++ operator

The postfix ++ operator returns a new instance with the same value as the operand, then increments the value of the operand by 1.

The operand must be one of the int, long, or real class. Otherwise, the operator will throw an exception.

Even if the operand is the maximum value for that class, the postfix ++ operator will not cause an overflow. It will be the minimum value of the class.


int i = 10;

int j = i++; // j is 10. i is 11.

If the operand returns the proxy class, the entity of the proxy is automatically used. The result is the same as calling the Entity getter of the proxy class.


int i = 10;

proxy pro = new proxy(i);

int j = 10 + pro++; // j is 20. i is incremented.

Postfix -- operator

The postfix -- operator returns a new instance with the same value as the operand, then decrements the value of the operand by 1.

The operand must be one of the int, long, or real class. Otherwise, the operator will throw an exception.

Even if the operand is the minimum value for that class, the postfix -- operator will not cause an overflow. It will be the maximum value of the class.


int i = 10;

int j = i--; // j is 10. i is 9.

If the operand returns the proxy class, the entity of the proxy is automatically used. The result is the same as calling the Entity getter of the proxy class.


int i = 10;

proxy pro = new proxy(i);

int j = 10 + pro--; // j is 20. i is decremented.

Copyright © Rice All rights reserved.