From: Ron Fox Date: 2008-05-29T20:29:55+09:00 Subject: Re: Merge collections of objects Unless this is a toy project, it will be important to think about what is it that makes two employees, one in companyA and one in companyB 'duplicates'...and what you really want to do in that case as the record information related to the emplyees may be different between the companies...all this is interesting business logic.. not a ruby question however. RF John Butler wrote: > Hi, > > I wonder if there is a quick way to do this. > > companyA has 2 employees "a", "b" > > companyB has 3 employees "a", "b", "c" > > I basically want to merge companyA employess with companyB employees so > when i look at companyA the employees will equal "a", "b", "c" > > i know i could do something like companyA.employees = companyB.employees > but this would just overwrite companyA employees so if companyA had more > employees than companyB i would lose the employees companyA had that > companyB didnt. > > I think companyA.employees << companyB.employees would just mash them > together and give me duplicates. > > The only other way i can think off is a nasty double loop that compares > each object 1 by 1 and then starts again going through the process. > > It would also be nice if the employees for companyB were removed but i > could do that separately. > > JB