From: Harry Kakueki Date: 2007-05-11T12:56:28+09:00 Subject: Re: how to remove dups from 2 lists? On 5/11/07, Harry Kakueki wrote: > On 5/11/07, Mike Steiner wrote: > > I'm trying to write some code that removes all elements from 2 lists that > > are in both lists. However, I don't want any duplicates from each list > > deleted also (which is what the array "-" operator does). The code I have > > If I understand correctly, I think this does what you want. > Oops! Correction. arr1 = %w[a a a b b b c d d e e] arr2 = %w[a b b b c c c d d d d d e a b] str1 = arr1.to_s str2 = arr2.to_s (arr1 & arr2).each do |x| str1.sub!(x,"") str2.sub!(x,"") end p str1.split(//) p str2.split(//) -- http://www.kakueki.com/ruby/list.html A Look into Japanese Ruby List in English