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…
May be a newbie question…
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…
May be a newbie question…
On 16 April 2010 14:22, Hemant B. [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).
Colin
Colin L. wrote:
On 16 April 2010 14:22, Hemant B. [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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs