From: Joe Seeley Date: 2006-08-17T23:08:42+09:00 Subject: Re: Array Comparison ------=_Part_9273_3503225.1155823719387 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline You could always add an XOR function to the Array class. class Array def XOR(i) return (i | self) - (i & self) end def ^(i) return XOR(i) end end It should be there already anyway, even if it is just syntactic sugar... On 8/17/06, Kroeger, Simon (ext) wrote: > > > > From: aidy [mailto:aidy.rutter@gmail.com] > > Sent: Thursday, August 17, 2006 1:35 PM > > > > Hi Guys > > > > I have compared an array and '0' is being returned which indicates to > > me that that array is equal > > > > p t = $ie.table(:index, '2').to_a.flatten > > p t <=> ["HINCKLEY", "HINDHEAD", "HINTON ST GEORGE"] > > > > Now would it be possible for me to extract any differences from this > > array (that is, when the array is not equal)? > > > > Or should I really be using Test::Unit: to assert array equality? > > > > aidy > > t = [2, 3, 4, 5] > > # use == if you want to test for equality > p t == [2, 3, 4, 5] # => true > > if t != [3, 4, 5, 6] > # you may use the array set methods to show the differences > p t - [3, 4, 5, 6] #=> [2] > p [3, 4, 5, 6] - t #=> [6] > p ([3, 4, 5, 6] | t) - ([3, 4, 5, 6] & t) #=> [6, 2] > end > > cheers > > Simon > > ------=_Part_9273_3503225.1155823719387--