Method

# Operator_Power

<div class="rst-class">

forsearch

</div>

Operator

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

## Description

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

## Notes

Create an <span class="title-ref">Operator_Power</span> function in a class to specify the functionality of the `^</api/language/operators/mathematical/^>` operator for that class. When you use the `^</api/language/operators/mathematical/^>` operator in your code to operate on two instances of the class, your <span class="title-ref">Operator_Power</span> function will be called.

In the function, the `Self</api/language/self_keyword>` instance the left operand and the other operand is passed as a parameter. The `Self</api/language/self_keyword>` instance is raised to the power specified by the passed instance.

## 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_Power</span> function that raises the sum of the `Self</api/language/self_keyword>` instance to the power of the passed instance.

``` xojo
Function Operator_Power(rhs As Vector) As Integer
  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/^>` operator; `Operator PowerRight</api/language/operators/operator_overloads/operator_powerright>` function.

</div>
