Colin Law wrote: > On 16 April 2010 14:22, Hemant Bhargava <[email protected]> wrote: >> Guyz, tell me one thing that if i have an array of object of type ABC.. >> then how to find the objects from that array which are uniq in id.. I >> mean unique by ABC.id.. > > If you have two with the same id how do you know which one you want? > > If you just mean that you want to strip out duplicate entries then > look at then just use abc.uniq (Have a look at the docs for the Array > class).
Depending on your requirements, another option is to use a Set instead of an Array. With a Set you won't end up with duplicates in the first place. -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

