From: Joe Bowers Date: 2006-05-17T03:26:22+09:00 Subject: Re: Enumerable#collect and #select best practices -----Original Message----- From: Daniel Schierbeck [mailto:daniel.schierbeck@gmail.com] > I need to collect the results of calling a method on each object in an > Enumerable that defines that method. Currently, I have this: > enum.collect{|obj| obj.a_method rescue nil }.compact > though this could also work: This looks like prime .inject territory enum.inject([]) do |l,obj| (l << obj.a_method) if obj.respond_to? :a_method end