Skip to content

Intrinsic Procedure __modulus__

IsaacShelton edited this page Mar 21, 2022 · 1 revision

'__modulus__' function

The __modulus__ function can be defined to allow additional types to be used with the modulo % operator.

func __modulus__(a $A, b $B) $C {

}

where $A, $B and $C are any valid types

Usage Example

import basics

struct ModIsAlwaysFive ()

func __modulus__(_unused_a, _unused_b ModIsAlwaysFive) int {
    return 5
}

func main {
    x ModIsAlwaysFive
    
    printf("x % x = %d\n", x % x)
}
x % x = 5
Clone this wiki locally