-
-
Notifications
You must be signed in to change notification settings - Fork 9
Modulo Operator
IsaacShelton edited this page Mar 21, 2022
·
1 revision
The %
operator is used for performing the modulo operation on two numeric types.
1 % 2
The %
operator can be defined for non-numeric types or type combinations with the following:
func __modulus__(a $A, b $B) $C
where $A
, $B
and $C
are any valid types
See __modulus__
for more information.
A common usage of the %
operator (for non-numeric types) is simple String
substitution:
"Welcome %!" % "Isaac"
Allowed by these definitions:
func __modulus__(lhs POD String, rhs String) String
func __modulus__(lhs POD String, rhs int) String
func __modulus__(lhs POD String, rhs ptr) String
func __modulus__(lhs POD String, rhs bool) String
func __modulus__(lhs POD String, rhs $T~__primitive__) String