Method

Operator_Negate


Description

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

Compatibility

All project types on all supported operating systems.

See also

- operator.