I have two classes, each of which use methods from the other class.  But
because they initialize an instance of each other, this creates an
infinite loop!

I would like to keep them separate and not merge them.  What's the best
/ most elegant / proper way of solving this problem?  There is probably
something simple that I'm just not seeing.

Simplified code:

class A
  def initialize
    b = B.new
  end

  def method_foo
    # do something with b
  end
end

class B
  def initialize
    a = A.new
  end

  def method_bar
    # do something with a
  end
end

Any help gratefully received!

-- 
Posted via http://www.ruby-forum.com/.