On Fri, 27 Jun 2003 10:48:56 +0900, Krishna Dole wrote:

> Hi,
> I'm having trouble using the & (intersection) method on two arrays of
> objects. I know that if the objects don't have comparison methods, & won't
> work because it is looking at the object IDs rather than values stored in
> the objects, but I can't seem to get & to use the comparison methods I want.
> 
[snip code] 
> p (foo & bar) # returns an empty array! NOOOOO!!!!!

There is no intersection(&) method.

I guess you have to do

  def &(anOther)
    @n & anOther.n
  end


Have you looked at 'set.rb' which is distributed with ruby ?

--
Simon Strandgaard