From: Guillaume Marcais Date: 2003-06-27T22:37:51+09:00 Subject: Re: Using & for arrays of objects On Fri, 2003-06-27 at 07:26, nobu.nokada@softhome.net wrote: > Hi, > > At Fri, 27 Jun 2003 09:48:56 +0900, > Krishna Dole wrote: > > 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. > > Array#& uses Hash internally due to performance, so you need to > define #hash and #eql? methods. > > -- > Nobu Nakada > I barely dare asking this because I know how tedious of a task maintaning documentation is. Nevertheless, could it be made clearer throughout the documentation what equality operator (hash/eql? or ==) a method relies on. It is not the first time I see confusion about it and I am a little confused myself from time to time. Just looking at the Array class, at least the following methods rely on an equality operator of its elements: -, &, delete (with no block), uniq, uniq!, eql?, <=>, ==, include?, index, rassoc, rindex. The methods from eql? on already specify which equality operator is being used. Thanks in advance, Guillaume.