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

From: jkrmr.io@...
Date: 2016-04-15 16:25:50 UTC
List: ruby-core #74973
Issue #12291 has been updated by Jake Romer.


Interestingly, I'm seeing the following on ruby 2.0.0p648:

```
[1] pry(main)> foo = Struct.new(:a, :a).new("1", "2")
=> #<struct  a="1", a="1">

```


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

* 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