Hash#each(each_pair)
#RubySilver
ブロック1つ
code:.rb
h = {a: 100, b: 250}
h.each {|x| p x }
# 出力
:a, 100 # array
:b, 250
ブロック2つ
code:.rb
h = {a: 100, b: 250}
h.each {|x, y| p "x: #{x}, y: #{y}" }
"x: a, y: 100"
"x: b, y: 250"
each_pair も同じ動作
code:.rb
h = {a: 100, b: 250}
h.each_pair {|x, y| p "x: #{x}, y: #{y}" }
"x: a, y: 100"
"x: b, y: 250"