From: Ben Zealley Date: 2006-07-21T04:25:10+09:00 Subject: Re: Using .each with constructors Mike Harris wrote: > The parallel assignment/array expansion approach suggested by patrick > and james will definitely work. You could also try > > [:a,:b,:c,:d].each { |x| eval "#{x} = SomeClass.new" } I notice the first two can be combined to a, b, c = Array.new(3) { SomeClass.new } losing both the .map and the |i|, and that still works (go Ruby! I continue to be amazed by how much it can work out...). But all of these leave an anonymous array of the variables sitting around, which doesn't get GC'd. Can it be done without that, or should I reduce my pedantic tendencies slightly and live with it? ;) Thanks for all the great responses! -- Ben