From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Global Method

Operator_Negate() As Type

Supported for all project types and targets.

Used to overload the - operator when used for negation, providing custom functionality.


Create an Operator_Negate function in a class to specify the functionality of the - operator for that class.

In the function, the definition of negation is given for the Self instance only. No parameters are passed.

Sample Code

In this example, the negation of the Vector class (see Operator_Add), a class with two Integer properties, x and y, is defined as the negative of the square length of the vector.

Function Operator_Negate As Integer
Var a As Integer
a = Self.x ^ 2 + Self.y ^ 2
Return -a
End If

See Also

- operator.