Difference between revisions of "Operator Modulo"

From Xojo Documentation

m
 
Line 1: Line 1:
{{MethodBox
+
{{DISPLAYTITLE:Operator_Modulo}}{{MethodBox
 
| name = Operator_Modulo
 
| name = Operator_Modulo
 +
| parameters = rightHandSide As Type
 +
| owner = global
 +
| scope = global
 
}}
 
}}
 +
 +
{{Description
 +
|text = Used to overload the [[Mod]] function, providing custom functionality. }}
 +
 +
{{DISPLAYTITLE:Operator_Modulo}}{{MethodBox
 +
| name = Operator_Modulo
 +
| returntype = [[Integer]]
 +
| owner = global
 +
| scope = global
 +
}}
 +
 
{{Description
 
{{Description
 
|text = Used to overload the [[Mod]] function, providing custom functionality. }}
 
|text = Used to overload the [[Mod]] function, providing custom functionality. }}

Latest revision as of 14:44, 3 August 2021

Global Method

Operator_Modulo(rightHandSide As Type)

Supported for all project types and targets.


Used to overload the Mod function, providing custom functionality.


Global Method

Operator_Modulo() As Integer

Supported for all project types and targets.


Used to overload the Mod function, providing custom functionality.

Notes

Create an Operator_Modulo function in a class to specify the functionality of the Mod operator for that class.

In the function, the Self instance the left operand and the other operand is passed as a parameter.

Sample Code

Using the Vector class (see Operator_Add) with two Integer elements, x and y, we define an Operator_Modulo function that returns the remainder of the division of the sum of the Self instance by the passed instance.

Function Operator_Modulo(rhs As Vector) As Integer
Var a, b As Integer
a = Self.x + Self.y
b = rhs.x + rhs.y

Return a Mod b
End Function

See Also

Mod operator; Operator_ModuloRight function.