Hi,

You have a very interesting case.  It seems that while array subtraction
is implemented internally using "rb_equal()" which invokes the
"==" method, array union (and some others) is implemented using some
hashing of the actual objects themselves.  I don't know a way to get what
you expect except to implement explicitly the method yourself in Ruby.

(Probably this is another candidate for "Things That Newcomers to Ruby
Should Know"? :) )

Regards,

Bill
============================================================================
Michael Halcrow <mah69 / email.byu.edu> wrote:
> Why do array subtraction and array union not behave in the same manner
> when operating on an array of user-defined objects? Specifically, how
> can I get the Array union operator to use the user-defined "==" method
> of the objects, as the Array subtraction operator does? What is the best
> way to get what I expect?

> Thanks,
> Mike