わたなべです.

GOTO Kentaro <gotoken / math.sci.hokudai.ac.jp> writes:

:collect は次の定義と等価と思っていいですか??
:
:module Enumerable
:  def collect(&block)
:    raise LocalJumpError, "yield called out of iterator" unless iterator?
:
:    res = []
:    each{|i| res.push (block.call i)}
:    res
:  end
:end

だいたい等価です.
C で書いてあることを Ruby で表現するとこんな感じですね.

module Enumerable
  def collect
    tmp = []
    each {|i| tmp.push yield(i)}
    tmp
  end
end

-- 
わたなべひろふみ