> 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