On 15.11.2008 20:51, Michael Guterl wrote: > On Sat, Nov 15, 2008 at 2:08 PM, Chad Perrin <perrin / apotheon.com> wrote: >> On Sun, Nov 16, 2008 at 02:27:45AM +0900, Tim Hunter wrote: >>> The way I read the ri doc for lineno=, it appears that all it does is >>> determine the value that lineno returns the next time you call it. That >>> is, it doesn't move the read position in the file. Exactly. >> The class is specced here, with the screen scrolled to where IO#lineno >> and IO#lineno= are listed: >> >> http://ruby-doc.org/core/classes/IO.html#M002289 >> > The description of the method is somewhat ambiguous if you ask me. I don't think so. > My view of the docs is inline with what Tim was describing. Same here. > ------------------------------------------------------------- IO#lineno= > ios.lineno = integer => integer > ------------------------------------------------------------------------ > Manually sets the current line number to the given value. +$.+ is > updated only on the next read. There is no talk about read position in the file - just about "current line number". Also: > f = File.new("testfile") > f.gets #=> "This is line one\n" > $. #=> 1 > f.lineno = 1000 > f.lineno #=> 1000 > $. # lineno of last read #=> 1 > f.gets #=> "This is line two\n" > $. # lineno of last read #=> 1001 The sample makes it very clear that the read position is not affected by lineno= because file reading obviously continues at the position where it was before. > I would think if it had the behavior you described, the second time > f.gets is called, we would see: "This is line one thousand and one\n" > not "This is line two\n" Right (if by "you" you do not mean Tim, somehow part of the thread is missing in Usenet). Kind regards robert