From: WATANABE Hirofumi Date: 1998-10-30T14:24:50+09:00 Subject: [ruby-list:10495] Re: Enumerable#collect bug? わたなべです. GOTO Kentaro 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 -- わたなべひろふみ