From: Florian Gross Date: 2004-10-11T04:59:39+09:00 Subject: Re: Putting some code out to DRY trans. (T. Onoma) wrote: > Notice the three lines of duplication. Any ideas on DRYing this up? > > def each > seed = @start @step ||= 1.0 / 0.0 # Infinity @step.times do yield(seed) @skip.times { seed = seed.succ } break if @halt and @halt.call(seed) > end > end And maybe this: (in case @start is numeric) def each (@start .. (1.0 / 0.0)).step(@skip) do |seed| yield(seed) break if @halt and @halt.call(seed) end end > Thanks, > T. Regards, Florian Gross