From: Gavin Sinclair Date: 2002-10-24T22:17:23+09:00 Subject: Re: Read "current line" from a file? From: > Hi, > > At Thu, 24 Oct 2002 18:57:49 +0900, > Gavin Sinclair wrote: > > Given an IO object, you can get the "next" line with #gets, right? > > > > Given an IO object, you can get the "current" line with #X, right? Please? > > What about this? > > class IO > module Backing > def gets(rs = $/) > @backing = super > end > def last > @backing > end > end > end > > STDIN.extend(IO::Backing) > p STDIN.gets > p STDIN.last That's quite nice. I pronounce this the best solution so far :) > Nobu Nakada Gavin