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:
enum.select do |obj|
obj.respond_to? :a_method
end.collect{|obj| obj.a_method }
although that’s a bit verbose.
Is there any best practices I should follow?
Daniel