Skip to content

Intrinsic Procedure __multiply__

IsaacShelton edited this page Mar 21, 2022 · 1 revision

'__multiply__' function

The __multiply__ function can be defined to allow additional types to be used with the multiply * operator.

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

}

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

Usage Example

import basics

struct MultiplicationIsAlwaysFive ()

func __multiply__(_unused_a, _unused_b MultiplicationIsAlwaysFive) int {
    return 5
}

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