From: Moises Machado Date: 2007-05-12T22:47:26+09:00 Subject: Re: how to remove dups from 2 lists? Mike Steiner wrote: > while results Well, this while loop will not terminate because [] is considered true in ruby, use this instead while results != [] or the more idiomatic while not results.empty? > a = a - m > b = b - m I don't think that this '-' works here, you probably meant: a.delete_at(a.index(m)) b.delete_at(b.index(m)) because a = a - [m] will remove all m's of a and make the code do the same as: a, b = a - (a&b), b - (a&b) although i like the elegance of that solution i prefer something like this: def removeDupsFromLists ( list1 , list2 ) x = list1.dup x.each do | i | if list2.include?(i) list1.delete_at( list1.index(i) ) list2.delete_at( list2.index(i) ) end end return [ list1, list2 ] end just because is easier to follow and to debug: there is no way of get an infinte loop MoisesMachado -- Posted via http://www.ruby-forum.com/.