Should OpenStruct implement #eql? and #hash?
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?
- lib/ostruct.rb: Add OpenStruct#eql? and OpenStruct#hash [ruby-core:42651] [Bug #6029]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Updated by marcandre (Marc-Andre Lafortune) about 6 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100