Ross Bamford
11/20/2006 3:47:00 PM
On Mon, 20 Nov 2006 15:33:33 -0000, David Lelong <drlelon@yahoo.com> wro=
te:
> Hi,
>
> I have a hash that contains the following keys/values:
>
> [#<Contact_List:0x2607150 @attributes=3D{"contact_id"=3D>"4"}>,
> #<Contact_List:0x2607114 @attributes=3D{"contact_id"=3D>"8"}>]
>
> I want to create an array containing the contact_id values. What's an=
> easy way to do this?
>
> Thanks,
>
> David
>
Assuming Contact_List (aside: why an underscored class name?) has an =
attr_accessor for 'attributes', you might try:
a.map { |clist| clist.attributes['contact_id'] }
(where 'a' is the array you show above).
-- =
Ross Bamford - rosco@roscopeco.remove.co.uk