From: Mathieu Bouchard Date: 2000-12-03T08:54:24+09:00 Subject: [ruby-talk:6756] Re: Array Intersect (&) question > |> >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. Oh, I see. > If no one requests order preservation, I will use > hashes in &, |, and uniq. What's your opinion? I think you can preserve order and use hashes. class Array def &(other) t = {} r = [] other.each {|x| t[x]=1 } uniq.each {|x| r<