Skip to content
Snippets Groups Projects
Commit 10949ad7 authored by Jack Nagel's avatar Jack Nagel
Browse files

Fix some #eql? correctness issues

The implementation of #eql? and #hash should ensure that if a.eql?(b),
then a.hash == b.hash, but #eql? itself should not *depend* on #hash.

For example, given

  class Thingy
    def eql?
      instance_of?(other.class) && hash == other.hash
    end

    def hash
      [name, *tags].hash
    end
  end

if #hash produces a collision for different values of [name, *tags], two
Thingy objects will appear to be eql?, even though this is not the case.
Instead, #eql? should depend on the equality of name and tags directly.
parent ad291d7f
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment