Bug #7382

Struct#each_pairのyieldと他のeach_pairのそれの相違

Added by tadayoshi funaba over 1 year ago. Updated over 1 year ago.

[ruby-dev:46533]
Status:Closed
Priority:Low
Assignee:Nobuyoshi Nakada
Category:-
Target version:2.0.0
ruby -v:ruby 2.0.0dev (2012-11-18 trunk 37708) [i686-linux] Backport:

Description

Struct#eachpairが他のeachpairと異なります。
他はENVなども含めてassocで、Structだけvaluesなので解りにくいです。

require 'ostruct'

h = {'a'=>1, 'b'=>2}
S = Struct.new('S', 'a', 'b')
s = S.new(1, 2)
o = OpenStruct.new(h)

h.eachpair{|x| p x}
s.each
pair{|x| p x}
o.each_pair{|x| p x}

Associated revisions

Revision 37721
Added by Nobuyoshi Nakada over 1 year ago

struct.c: yield assoc in each_pair

  • struct.c (rbstructeach_pair): yield associated pairs so that an unsplat argument can get both, for consistency with Hash, OpenStruct, and etc. [Bug #7382]

Revision 37722
Added by Nobuyoshi Nakada over 1 year ago

struct.c: fix typo

  • struct.c (rbstructeach_pair): fix typo. [Bug #7382]

History

#1 Updated by Yukihiro Matsumoto over 1 year ago

  • Assignee set to Nobuyoshi Nakada
  • Target version set to 2.0.0

おっしゃることはもっともなので、直してトラブルが起きないかどうか確認したいです。
中田さん、お願いしていい?

Matz.

#2 Updated by Yukihiro Matsumoto over 1 year ago

  • Status changed from Open to Assigned

#3 Updated by Nobuyoshi Nakada over 1 year ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r37721.
tadayoshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


struct.c: yield assoc in each_pair

  • struct.c (rbstructeach_pair): yield associated pairs so that an unsplat argument can get both, for consistency with Hash, OpenStruct, and etc. [Bug #7382]

Also available in: Atom PDF