From: Robert Klemme Date: 2005-11-08T03:32:11+09:00 Subject: Re: an array of hashes Francesco wrote: > Hello all! > Can this be done better/nicer? > In @person i have an array of telephones. telephone is a hash with an > id and a number, and i would like to join them. > > @person.telephones.collect {|x| [] << x.number}.join(', ') > > I don't know why, but I don't like this line of code... how would you > write it? Two things are odd: 1. there is no hash dereferencing in your code 2. you're creating one element arrays all the time in a weired way. Why don't you just do this? @person.telephones.collect {|x| x.number}.join(', ') Kind regards robert