Method

# Operator_SubtractRight

<div class="rst-class">

forsearch

</div>

Operator

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to overload the `-</api/language/operators/mathematical/->` operator, providing custom functionality. <span class="title-ref">Operator_SubtractRight</span> is the same as `Operator Subtract</api/language/operators/operator_overloads/operator_subtract>` but the implicit `Self</api/language/self_keyword>` instance is on the right instead of the left in the subtraction.

## Notes

Create an <span class="title-ref">Operator_SubtractRight</span> function in a class to specify the functionality of the `+</api/language/operators/mathematical/+>` operator for that class.

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

<div class="important">

<div class="title">

Important

</div>

This is not currently supported for Android.

</div>

## Sample code

Suppose you have a class, Vector, that can store a vector. To define the `-</api/language/operators/mathematical/->` operator for this class, create a method of the Vector class called <span class="title-ref">Operator_SubtractRight</span>.

The Vector class has two `integer</api/data_types/integer>` properties, x and y.

Operator_SubtractRight is defined as:

``` xojo
Function Operator_SubtractRight(lhs As Vector) As Vector
  ' lhs stands for left-hand-side, the vector to be added to Self
  Var ret As New Vector ' the difference between the two vectors
  ret.x = lhs.x + Self.x
  ret.y = lhs.y + Self.y
  Return ret
End Function
```

## Compatibility

|                       |                               |
|-----------------------|-------------------------------|
| **Project Types**     | Console, Desktop, Mobile, Web |
| **Operating Systems** | iOS, Linux, macOS, Windows    |

<div class="seealso">

`-</api/language/operators/mathematical/->` operator, `Operator Subtract</api/language/operators/operator_overloads/operator_subtract>` function.

</div>
