From: matz@... (Yukihiro Matsumoto) Date: 2003-02-21T04:18:24+09:00 Subject: Re: Inconsistent behavior in Array methods Hi, In message "Inconsistent behavior in Array methods" on 03/02/21, "Warren Brown" writes: | I recently tracked down a bug in my code to a line that read: | | cards = cards.sort.uniq | | This seemed perfectly reasonable - the cards array contained Card |objects which were Enumerable. However, the bug was due to the fact that |Array#uniq does not use the object's == method to do comparisons - even |though Array#sort uses the object's <=> method. Upon investigation, I found |that the implementation of Array#uniq uses a hash, and since the key to the |hash is the object ID, uniqueness ends up being defined as (obj1.id == |obj2.id). This was *surprising* to me. I know, but I thought the order of execution time was more important, especially for big arrays. matz.