Project

General

Profile

Actions

Bug #7382

closed

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

Added by tadf (tadayoshi funaba) about 12 years ago. Updated about 12 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.0.0dev (2012-11-18 trunk 37708) [i686-linux]
Backport:
[ruby-dev:46533]

Description

Struct#each_pairが他のeach_pairと異なります。
他は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.each_pair{|x| p x}
s.each_pair{|x| p x}
o.each_pair{|x| p x}

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0