Project

General

Profile

Bug #19622

Updated by tycooon (Yuri Smirnov) about 1 year ago

Currently, the [Array#& docs](https://ruby-doc.org/3.2.2/Array.html#method-i-26) [docs](https://ruby-doc.org/3.2.2/Array.html#method-i-26) only state that the objects are compared using `eql?` method. However, it turns out that if arrays are "big" (size more than `SMALL_ARRAY_LEN`), then the hash is used so things stop working unless you also redefine `hash` method. I know that there is information regarding that in the `eql?` method docs (see https://ruby-doc.org/3.2.2/Object.html#method-i-eql-3F), however it's very likely that people will just go ahead and define the `eql?` method and everything will work until some point in time. 

 So I think it would be great to update the docs for Array method `&`, `intersection` and `intersect?` to clearly state that both `eql?` and `hash` methods are used.

Back