# Priority 7 operators

 == x == y Value equality operator != x != y Value inequality operator \$\$ x \$\$ y Reference equality operator !\$ x !\$ y Reference inequality operator

They are binary comparison operators and have left-associativity. the equivalence of operands is compared and result is returned as the bool class.

There are two criteria for equivalence: value and reference.

Value equality operator

Value inequality operator

Reference equality operator

Reference inequality operator

## Value equality operator

Value equality operator returns true when operands are equal in value. Otherwise, returns false.

bool result0 = 10 == 10; //The result is true;

bool result1 = 10 == 11; //The result is false;

bool result2 = "string" == "string"; //The result is true;

bool result3 = "string" == "strin"; //The result is false;

Operands must be a class that represents the value: int, long, real, string, and bool.

When operands are string or bool, both operands must be the same class. Otherwise, an exception will be thrown.

When operands are int, long, or real, You can mix these in operands.

If operands return 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;

real r = 10.5;

proxy pro = new proxy(i);

proxy pro2 = new proxy(r);

bool b = pro2 == pro; // b is false.

## Value inequality operator

Value inequality operator returns true when operands are not equal in value. Otherwise, returns false.

bool result0 = 10 != 10; //The result is false;

bool result1 = 10 != 11; //The result is true;

bool result2 = "string" != "string"; //The result is false;

bool result3 = "string" != "strin"; //The result is true;

Operands must be a class that represents the value: int, long, real, string, and bool.

When operands are string or bool, both operands must be the same class. Otherwise, an exception will be thrown.

When operands are int, long, or real, You can mix these in operands.

If operands return 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;

real r = 10.5;

proxy pro = new proxy(i);

proxy pro2 = new proxy(r);

bool b = pro2 != pro; // b is true.

## Reference equality operator

Reference equality operator returns true when operands are equal as reference. Otherwise, returns false.

int i = 10;

int j = i;

bool result0 = i \$\$ j; //The result is true;

bool result1 = i \$\$ 10; //The result is false;

There are no restrictions on the operands.

"equal as reference" means whether operandes are referring to the same address.

## Reference inequality operator

Reference inequality operator returns true when operands are not equal as reference. Otherwise, returns false.

int i = 10;

int j = i;

bool result0 = i !\$ j; //The result is false;

bool result1 = i !\$ 10; //The result is true;

There are no restrictions on the operands.

"equal as reference" means whether operandes are referring to the same address.