From: Robert Klemme Date: 2012-12-12T22:36:22+09:00 Subject: Re: Enumerable#zip with File IO On Wed, Dec 12, 2012 at 12:51 PM, 林彰史 wrote: > Yes I agree that it makes no sense, but I wanted to see how zip method works > with File IO with a simple experimental code. > My point is why the second line of input is discarded. That might be an artifact of unhealthy using of the Enumerator because you do not really iterate through the whole file but you use it twice on the same file. Chances are that the Enumerator fetches the next item before it is actually uses and #zip just breaks out of the loop prematurely. In your example you'd rather want [1, 2].zip( file.each ) do |n,l| puts "#{n}: #{l}" end Or you want to reverse order and do file.zip([1, 2]) do |l, n| puts "#{n}: #{l}" end Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/