Skip to content
Snippets Groups Projects
  • Jack Nagel's avatar
    10949ad7
    Fix some #eql? correctness issues · 10949ad7
    Jack Nagel authored
    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.
    10949ad7
    History
    Fix some #eql? correctness issues
    Jack Nagel authored
    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.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.