-
-
Notifications
You must be signed in to change notification settings - Fork 9
Intrinsic Procedure __subtract__
IsaacShelton edited this page Mar 21, 2022
·
1 revision
The __subtract__
function can be defined to allow additional types to be used with the subtract -
operator.
func __subtract__(a $A, b $B) $C {
}
where $A
, $B
and $C
are any valid types
import basics
struct SubtractionIsAlwaysFive ()
func __subtract__(_unused_a, _unused_b AdditionIsAlwaysFive) int {
return 5
}
func main {
x AdditionIsAlwaysFive
printf("x - x = %d\n", x - x)
}
x - x = 5