From: Alexey Verkhovsky Date: 2004-10-11T04:51:18+09:00 Subject: Re: Putting some code out to DRY On Sun, 2004-10-10 at 22:25, trans. (T. Onoma) wrote: > Notice the three lines of duplication. Any ideas on DRYing this up? I would extract them into a method. Another alternative, at a price of checking @step on every iteration, and much less readable than your original: # UNTESTED def each seed = @start counter = 0 loop do break if @step and (counter += 1) > step yield(seed) @skip.times { seed = seed.succ } break if @halt.call(seed) if @halt end end