From: Robert Klemme Date: 2007-02-09T18:05:14+09:00 Subject: Re: Iterators and blocks question On 08.02.2007 23:44, Timothy Hunter wrote: > Bharat Ruparel wrote: > counter = 1 > IO.foreach("test.txt") {|line| puts "#{counter}. #{line}"; counter += 1} An injectified version of this: require 'enumerator' IO.to_enum(:foreach, "test.txt").inject(0) do |counter, line| puts "#{counter}. #{line}" counter + 1 end :-) robert