IO#each counts lineno
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|
Updated by drbrain (Eric Hodel) over 11 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r32465.
b, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- io.c: Note that methods other than IO#gets may increase IO#lineno.
[Ruby 1.9 - Bug #4902]