I have a class such as

Class Foo
  def initialize(x)
    @x = x
  end
  attr_read :x
end

I want to be able to multiply a NUMERIC object by my Foo object and have
it return a new Foo object with all the instance variables multiplied by
the Numeric object.  For example:

y = Foo.new(3)
z = 2*y
print z.x => 6

or

z = 2.0*y
print z.x => 6.0

I'm thinking I have to modify the "*" method for all the subclasses of
the NUMERIC class.  Is this correct?  Or am I missing something.

I know I can put a "*" method in my Foo class, and get it to do things
like "y*2", but how do I get "2*y"?

Thanks in advance.
-- 
Posted via http://www.ruby-forum.com/.