From: Joel VanderWerf Date: 2009-08-04T14:33:15+09:00 Subject: Re: How to extract only needed attribute from an array Thriving K. wrote: > I have an object called Tags with id and name ==> [ tag.id , tag.name] > > | [1 , aaa] | > > | [ 3 , bbb] | > > | [ 5 , ccc] | > > | [ 6 , dfd] | > > | [ 7 , waf] | > > | [ 11 , vee] | > > There is an array with the list of tags , i just want to extract all > tag.id > as a new array, what is the easiest way to do Is this how your array looks? a = [ [1 , :aaa], [ 3 , :bbb], [ 5 , :ccc], [ 6 , :dfd], [ 7 , :waf], [ 11 , :vee] ] p a.transpose[0] # ==> [1, 3, 5, 6, 7, 11] Or: p a.map {|b| b[0]} -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407