Operator_Negate

From Xojo Documentation

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.

Notes

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.