Method

# Operator_Divide

<div class="rst-class">

forsearch

</div>

Operator

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

## Description

Used to overload the `/</api/language/operators/mathematical/division>` operator, providing custom functionality.

## Notes

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

In the function, the `Self</api/language/self_keyword>` instance is the left operand and the other operand is passed as a parameter.

## Sample code

Using the Vector class (see `Operator Add</api/language/operators/operator_overloads/operator_add>`) with two `Integer</api/data_types/integer>` elements, x and y, we define an <span class="title-ref">Operator_Divide</span> function that divides the sum of the `Self</api/language/self_keyword>` instance with the sum of the passed instance.

``` xojo
Function Operator_Divide(rhs As Vector) As Double
  Var a, b As Integer
  a = Self.x + Self.y
  b = rhs.x + rhs.y
  Return a / b
End Function
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`/</api/language/operators/mathematical/division>` operator; `Operator DivideRight</api/language/operators/operator_overloads/operator_divideright>` function.

</div>
