From Xojo Documentation

Revision as of 08:14, 22 August 2021 by RobinLM (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Used to overload the * operator, providing custom functionality.


Create an Operator_MultiplyRight function in a class to specify the functionality of the * operator for that class.

In the function, the Self instance is the operand on the right and the other operand is passed as a parameter.

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

Sample Code

Using the Vector class (see Operator_Add) with two Integer elements, x and y, we define an Operator_MultiplyRight function that multiplies the sum of the passed instance with the Self instance.

Function Operator_MultiplyRight(lhs As Vector) As Integer
Var a, b As Integer
a = Self.x + Self.y
b = lhs.x + lhs.y

Return b * a
End Function

See Also

* operator; Operator_Multiply function.