On Oct 10, 10:47 am, "Robert Dober" <robert.do... / gmail.com> wrote: > I do however feel very bad about the duplicate elimination of Array#& > this really seems to be worth a RCR, Arrays are just not sets from a > conceptional POV and from a practical POV we have uniq if we want to > be the result unique. > > a1 - (a1 - a2 ) > which is the best effort one can make ( I guess ) just seems not so > readable anymore, and it is not an idiom frequently used so one does > not get easily acquainted to it :( > Maybe Array#intersect would be nice to have too? Well a1 - (a1 - a2) is not necessarily the same as a2 - (a2 - a1). The difference is whether the duplicates in a1 are maintained (the former) or the duplicates is a2 are maintained. For example, suppose a1 is [1, 1, 2, 3, 4] and a2 is [1, 2, 2, 3, 5]. The result would be either [1, 1, 2, 3] or [1, 2, 2, 3]. If you wanted the & operator to maintain duplicates, would it maintain duplicates on the left-hand side, the right-hand side, or both? And if it is the LHS or RHS, then we've lost commuatativity (a1 & a2 is not necessarily equal to a2 & a1). Eric P.S. What is "RCR"? ---- Interested in hands-on, on-site Ruby training? See http://LearnRuby.com for information about a well-reviewed class.