On Fri, Feb 02, 2007 at 05:49:38AM +0900, Giant Cranes wrote:
> Hi,
> 
> I am pulling my hair out trying to figure out the following problem (my
> fault not rubys):
> 
> I have an array of hashes as follows:
> 
> a = Array.new
> a << {:name => 'tony', :age => 23}
> a << {:name => 'mary', :age => 57}
> a << {:name => 'dom', :age => 17}
> 
> I am trying to create an array with one attribute from each hash:
> 
> ['tony', 'mary', 'dom']
> 
> Any clues on how I should do this would be much appreciated.
 
a.collect {|e| e[:name]}

-- 
Jos Backus
jos at catnook.com