Issue #6029 has been reported by Marc-Andre Lafortune.

----------------------------------------
Bug #6029: Should OpenStruct implement #eql? and #hash?
https://bugs.ruby-lang.org/issues/6029

Author: Marc-Andre Lafortune
Status: Open
Priority: Normal
Assignee: Marc-Andre Lafortune
Category: lib
Target version: 2.0.0
ruby -v: r34620


Currently, OpenStruct have no specialized #eql? and #hash, so:

    require 'ostruct'
    x = OpenStruct.new(foo: 42)
    y = x.dup
    x == y    # => true
    x.eql?(y) # => false

This means that OpenStruct does not behave like Struct, Array, Hash and other structures by comparing its fields and values.

This also prevents using OpenStructs as hash keys (unless one uses the exact same object as the key), contrary to other structures.

Is there an historical reason for this?

How likely would it be that adding #eql? and #hash create conflict with some fields?



-- 
http://bugs.ruby-lang.org/