なんとなくyieldのイメージがつかめた気がする

すげぇ便利くさい。

# Array#eachの(粗製乱造の)類似品
def iich(arr) # 引数に配列を取る
  idx = 0
  while idx < arr.size
    yield(arr[idx]) # 引数の各要素毎に、その要素を引数にしてブロックを起動
    idx += 1
  end
end

http://www.ruby-lang.org/ja/man/?cmd=view;name=%A5%E1%A5%BD%A5%C3%A5%C9%B8%C6%A4%D3%BD%D0%A4%B7#yield

たとえば

StructA = Struct.new("StructA",:a,:b,:c)
class StructB < StructA
 def each_elem
  e = %w(a b c)
  i = 0
  e.each do |elem|
   yield(elem,self.send(elem))
  end
 end
end

test = StructB.new
test.a = "111"
test.b = "222"
test.c = "333"

test.each_elem do |key,data|
   p "#{key}::#{data}"
end
#=>
"a::111"
"b::222"
"c::333"

自分的にキタコレ