From: stephen O'D Date: 2009-04-09T07:00:05+09:00 Subject: Re: Instantiate different class based on variable contents On Apr 8, 10:01 pm, Tony Arcieri wrote: > [Note:  parts of this message were removed to make it a legal post.] > > On Wed, Apr 8, 2009 at 2:40 PM, stephen O'D wrote: > > > dispatch = { > >  'Foo' => Foo, > >  'Bar' => Bar > > } > > > obj = dispatch[var].new(...) > > > Is there another Ruby way to do this sort of thing? > > Object.const_get(var).new(...) > > or with ActiveSupport: > > var.constantize.new(...) > > -- > Tony Arcieri > medioh.com Thanks, works perfectly!