From: Orion Hunter Date: 2003-06-10T03:43:42+09:00 Subject: array.uniq does not use == ? I have a user defined object, Agent. And I want to pass my Agents around in an Array. I've "mixed-in" the Comparable module, and defined <=> within the class for sorting purposes. However, I _also_ want to be able to perform Array.uniq/Array.uniq! as well, having the decision on the "uniqueness" of the object derived from one particular attribute. My first thought was that all I need to do was define == in my Agent, and I had hoped/assumed that this was the operator/function that Array.uniq looked at when it executed. However, this is not the case. My next thought was that Array.uniq might use <=>, and consider them "equal" if this returned 0, however this was not the case either. I have tried defining the following for my object: <=> == === eql? equal? but none of them seem to be used in the Array.uniq comparison. Further investigation showed that a combination of overriding eql?() and hash() will do the trick (are these _both_ used in uniq?). Now, I know that I can create my own class which inherits from Array, and override the uniq and uniq! funciton to do what I want, but it seems like there is a less clumsly solution (it just seems like I shouldn't have to override hash()). Any suggestions? Thanks. Matt _________________________________________________________________ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963