From: Caleb Clausen Date: 2010-03-03T04:36:44+09:00 Subject: Re: Array#join using to_a if defined On 3/1/10, Benoit Daloze wrote: > Also, while playing with Array, using Array#&, I saw it look on #eql? and > #hash methods. These two methods are relative to Hash usually, I didn't > expect methods of Array to depends of them. It's because the efficient (O(1)) implementation of Array#& requires creating a temporary hash (or 2?) internally. However, this would seem to be an internal detail and callers should not have to know about it, as your example (quoted below) demonstrates. > A surprising result to me: > > irb for ruby-1.9.2-r26764 >> [1,2]&[2] > => [2] >> class N >> def initialize(n) >> @n = n >> end >> attr_reader :n >> def == o >> @n == o.n >> end >> end > => nil >> [N.new(1),N.new(2)]&[N.new(2)] > => [] # instead of [#] >