>>>>> "E" == Eric Bennett <ericb / eb.to> writes:

E> def coerce(x)
E> 	[ self, x ]
E> end

E> The way it is now if you change +:

 You'll have a problem with -


pigeon% cat b.rb
#!/usr/bin/ruby
class One
   def + (x)
      1+x
   end
   def -(x)
      1-x
   end
   def coerce(x)
      [self, x]
   end
end

one = One.new
p one - 3
p 3 - one
pigeon% 

pigeon% b.rb
-2
-2
pigeon% 


Guy Decoux