class Fixnum alias_method :old_plus, :+ def +(*args) old_plus(*args).old_plus(1) end end 2 + 2 #=> 5
class Fixnum alias_method :old_plus, :+ def +(other) return 5 if (self == 2 && other == 2) old_plus(other) end end
let (+) x y = match (x,y) with (2,2) -> 5 | (x,y) -> x+y;;
let (+) 2 2 = 5 in 2+2;;
proc `+`(x, y: int): int = result = x result.inc(y) result.inc echo(2 + 2) # => 5