Project

General

Profile

Actions

Bug #12291

closed

Struct member accessor is not consistent with hash access when keys are repeated

Added by jcole1989 (James Coleman) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
[ruby-core:74971]

Description

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"}
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0