23 Jul 06:22
Extracting one column from an array of objects
From: Ro Ma <rails-mailing-list@...>
Subject: Extracting one column from an array of objects
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2008-07-23 04:24:43 GMT
Subject: Extracting one column from an array of objects
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2008-07-23 04:24:43 GMT
This seems really simple but I can't seem to find an answer. Say I have an array of Users which has a column called 'id'. I need an array that holds just the ids. Right now I'm doing: for user in users ids << user.id end Is there a method to do this? Note that these objects aren't from my database so I can't use find. -- -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@... To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
RSS Feed