Peter Szinek wrote: > David Lelong wrote: >> Hi, >> >> I have a hash that contains the following keys/values: >> >> [#<Contact_List:0x2607150 @attributes={"contact_id"=>"4"}>, >> #<Contact_List:0x2607114 @attributes={"contact_id"=>"8"}>] >> >> I want to create an array containing the contact_id values. What's an >> easy way to do this? > > Try this: > > result = x.inject([]) {|a,h| a << h.values[0]; a} Sorry I have overlooked a little detail... My solution would work if the original array would contain [{"contact_id"=>"4"}, {"contact_id"=>"8"}] For the original question, the answer should be probably result = x.inject([]) {|a,h| a << h.attributes.values[0]; a} HTH, Peter __ http://www.rubyrailways.com