From: Robert Klemme Date: 2006-08-17T20:55:06+09:00 Subject: Re: Array Comparison On 17.08.2006 13:32, aidy wrote: > 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? You can use Array#zip (block form) to determine any differences. ["HINCKLEY", "HINDHEAD", "HINTON ST GEORGE"].zip(t) do |a,b| if a != b print "Difference: ", a.inspect, " ", b.inspect, "\n" end end Kind regards robert