From: "Brian F. Feldman" Date: 2000-12-03T08:37:28+09:00 Subject: [ruby-talk:6755] Re: Array Intersect (&) question matz@zetabits.com (Yukihiro Matsumoto) wrote: > Hi, > > In message "[ruby-talk:6723] Re: Array Intersect (&) question" > on 00/12/02, Mathieu Bouchard writes: > | > |> >Use a hash. Here's code to do both and more. It assumes that > |> >each element is unique in a given array: > > Using a hash makes it pretty fast, but it does not preserve the > original order. If no one requests order preservation, I will use > hashes in &, |, and uniq. What's your opinion? Personally, I feel that a non-ordered &() method would violate the POLS for a lot of people, including myself. How about adding a faster version as intersection(), then? I'm sure a similar situation exists with |() and can be optimized by making a new union(). I like highly deterministic API calls - preserving order and object duplication would be the only reasonable default, in my humble opinion. If the semantics really are changed, it would be nice to have a standard ordered_intersection() for people who want the old behavior... -- Brian Fundakowski Feldman \ FreeBSD: The Power to Serve! / green@FreeBSD.org `------------------------------'