From: Brian Candler Date: 2008-12-05T18:02:00+09:00 Subject: [ruby-core:20364] Re: [Bug #822] gets blocks when it shouldn't On Fri, Dec 05, 2008 at 10:40:56AM +0900, Nobuyoshi Nakada wrote: > > And also mention that such a sequence is replaced with two > > newlines? > > It is "dropped" rather than "replaced". > > How do you think this? .. > + * a time (two successive newlines in the input separate paragraphs, > + * and following successive newlines are dropped). Better, but now it doesn't say that preceding newlines are dropped. r,w = IO.pipe w.write("\n\n\n\n\nsome text\n\n\n\n\nmore text\n\n\n\n\nabc\n") puts r.gets("").inspect puts r.gets("").inspect puts r.gets.inspect Outputs: "some text\n\n" "more text\n\n" "abc\n" I'm not sure how best to describe this, except algorithmically: When reading a 'paragraph': * any initial newlines are discarded * data is read up to and including two successive newlines * any subsequent newlines are discarded * the read data is returned