From: jos@... (Jos Backus) Date: 2002-06-07T04:53:23+09:00 Subject: Returning an instance from a different class from new [For some reason I am no longer subscribed to ruby-talk and I don't get any mail back from the ctl address, which is why I have to use my provider's crappy newsserver :-(] How do I make the following return Bar instead of Foo? class Foo def initialize(sel) case sel when "1" return Bar.new when "2" return Baz.new end end end class Bar < Foo def initialize self end end class Baz < Foo def initialize self end end o = Foo.new("1") p o.type Thanks, Jos -- Jos Backus _/ _/_/_/ Santa Clara, CA _/ _/ _/ _/ _/_/_/ _/ _/ _/ _/ jos@catnook.com _/_/ _/_/_/ use Std::Disclaimer;