Operator_AddRight Method

Used to overload the + operator, providing custom functionality. Operator_AddRight is the same as Operator_Add but the implicit Self instance is on the right instead of the left in the addition.

Syntax

# Notes

Create an Operator_AddRight function in a class to specify the functionality of the + operator for that class and the Self instance is on the right.

The ordinary methods are always preferred; REALbasic uses the Right versions only if there is no legal left version.

# Example

Suppose you have a class, Vector, that can store a vector of modest size. To define the + operator for this class, create a method of the Vector class called Operator_AddRight.

The Vector class has two Integer properties, x and y.

Operator_AddRight is defined as:

Function Operator_AddRight (lhs as Vector) as Vector
//lhs stands for left-hand-side, the vector to be added to Self
Dim ret as New Vector the sum of the two vectors
ret.x=lhs.x + Self.x
ret.y=lhs.y + Self.y
Return ret

# See Also

+ operator, Operator_Add function.