From: YANAGAWA Kazuhisa Date: 2006-01-12T21:11:31+09:00 Subject: Re: Merge two arrays? In Message-Id: <7890ecfa1ecf4ba63d489bcce21a1d3e@ruby-forum.com> Joshua Muheim writes: > array1 = [1,2,4,6] > array2 = [1,3,5,6] > > 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 For former Array#& can be used if there're no duplicated elements in your arrays. For latter, hmm, I can't remember no one methods but you can (array1|array2)-(array1&array2), on same assumption. Note these operators always make a new array for a result, they may not be suitable when both your arrays are too large, though -- kjana@dm4lab.to January 12, 2006 Time and tide wait for no man.