From: Mike Steiner Date: 2007-05-11T11:18:15+09:00 Subject: how to remove dups from 2 lists? ------=_Part_78098_4715681.1178849894757 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 now doesn't handle restarting the current iteration for both loops when a match is found and deleted in both loops. Here's the code: def RemoveDupsFromLists ( list1 , list2 ) list1.each_index do | i | list2.each_index do | j | if list1[i] == list2[j] list1.delete_at ( i ) list2.delete_at ( j ) end end end return [ list1 , list2 ] end What's weird is that doing this is easy in C (my first language), but difficult in Ruby. Everything else I've seen has been MUCH easier in Ruby. Mike Steiner ------=_Part_78098_4715681.1178849894757--