Extracting one column from an array of objects

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.

You should be able to use ids= users.collect {|u| u.id}

G.

u can also do like

@ids = User.find(:all, :select => 'id', :order=>'id')

Say I have an array of Users which has a column called 'id'. I need an
array that holds just the ids.

ids = users.collect(&:id)

users.map { |user| user.id }

Samuel Flores

!#x000a