I have the following class:
class Register
attr_accessor :val
def initialize
@val = 0
end
end
I wish to be able to, given ax=Register.new
, type 3 + ax
or ax + 3
and get as a result the equivalent of 3 + ax.val
. I tried searching but can't find how this is done in Ruby.