[ruby-core:74971] [Ruby trunk Bug#12291] Struct member accessor is not consistent with hash access when keys are repeated

From: jtc331@...
Date: 2016-04-15 16:12:23 UTC
List: ruby-core #74971
Issue #12291 has been reported by James Coleman.

----------------------------------------
Bug #12291: Struct member accessor is not consistent with hash access when keys are repeated
https://bugs.ruby-lang.org/issues/12291

* Author: James Coleman
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
~~~
irb(main):001:0> foo = Struct.new(:a, :a).new("1", "2")
=> #<struct a="1", a="2">
irb(main):002:0> foo.a
=> "2"
irb(main):003:0> foo['a']
=> "1"
irb(main):004:0> foo.members
=> [:a, :a]
irb(main):005:0> foo.to_h
=> {:a=>"2"}
~~~



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

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next