From: Brian Mitchell Date: 2006-01-12T20:12:26+09:00 Subject: Re: Merge two arrays? On 1/12/06, Joshua Muheim wrote: > array1 = [1,2,4,6] > array2 = [1,3,5,6] > > Is there an easy way for doing this? > > array1 ?? array2 = [1,6] # Only add entries that occur in both arrays > array1 ?? array2 = [2,3,4,5] # Only add entries that occur in one of > both arrays array1 & array2 #=> [1,6] the second is harder but you could do it like: (array1 + array2) - (array1 & array2) #=> [2,3,4,5] I am not sure if that can be made simpler but it should work. Brian.