Here's a Ruby solution that really does modify the + operation: class Fixnum alias_method :old_plus, :+ def +(*args) old_plus(*args).old_plus(1) end end 2 + 2 #=> 5
Here is a Nimrod version which does the same:
proc `+`(x, y: int): int =
result = x
result.inc(y)
result.inc
echo(2 + 2) # => 5