From: Jean Nibee Date: 2007-03-01T13:21:22+09:00 Subject: Re: Array comparison.. why does this work. > > You're not doing comparison, though; you're doing subtraction. > Subtraction doesn't depend on order. You can think of it as > "without": > > [1,2,3] - [1] => [2,3] # [1,2,3] without 1 > [1,2,3,1] - [1] => [2,3] # [1,2,3,1] without 1 > [1,2,3] - [2] => [1,3] # [1,2,3] without 2 > > etc. > > > David Sorry, when I mentioned comparison I meant "Under the hood". (I realise '-' is subtractions ), but the interpreter needs to perform comparisoin to see if an element exists somewhere. I was curious if it just interates through one array looking for that element in the second, or does it (internally) sort the array, iterate each array performing comparision and if a > b skipping the equality determination to save CPU cycles and doing a 'next'. I guess what I"m saying (Makes more sense when you see pseudo code) is how does it work in the interpreter. -- Posted via http://www.ruby-forum.com/.