From: Robert Klemme Date: 2009-08-04T18:48:47+09:00 Subject: Re: How to extract only needed attribute from an array 2009/8/4 Thriving K. : > > 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 In any case you need method #map. In 1.9* you can even do use map(&:id): irb(main):001:0> Tag = Struct.new :id, :name => Tag irb(main):002:0> a = Array.new(5) {|i| Tag.new(i, "n"*i)} => [#, #, #, #, #] irb(main):003:0> a.map(&:id) => [0, 1, 2, 3, 4] Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/