Issue #4902 has been reported by b t.

----------------------------------------
Bug #4902: IO#each counts lineno
http://redmine.ruby-lang.org/issues/4902

Author: b t
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 
ruby -v: ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]


The docs for IO#lineno state that:
lineno counts the number of times gets is called, rather than the number of newlines encountered.

However, IO#each also increases the lineno variable. Running this piece of code on a text file will print the last line number twice:

File.open('file.txt', 'r') do |f|
  f.each_line do |l|
      puts f.lineno
  end
  f.gets
  puts f.lineno
end



-- 
http://redmine.ruby-lang.org