From: Siep Korteling Date: 2008-07-15T07:10:16+09:00 Subject: Re: array of hashes (finding value) Nate Leavitt wrote: > Glen Holcomb wrote: >> in an array at the index corresponding to :id. Although if this is >> coming >> out of Rails that probably isn't a viable option. If you are stuck with >> that construct then what you have should work fine. There are probably >> faster/more efficient ways though. > > > Thanks for the reply. Yes, I am working in rails :) It just seems > kinda tedious to keep iterating over all these collections. Just > wondering if there is a more efficient way. invoice_set=@invoices.select{|invoice|invoice[:id]==params[:contact_id]} invoice_set.each do |invoice| #stuff with invoice end Doubt if it is less work but it feels snappier somehow. Regards, Siep -- Posted via http://www.ruby-forum.com/.