From: Robert Klemme Date: 2010-05-10T20:48:25+09:00 Subject: Re: multiline gets ? 2010/5/10 Luis Parravicini : > Hi > > 2010/5/10 Une Bévue : >> if a use : >> sml = "" >> while s = STDIN.gets >>  sml += s >> end >> >> i get two times what's on STDIN, why ? >> may be something to flush, generally it's stdout hum ? > > Are you sure? How did you check that? > > irb(main):001:0> sml = "" > => "" > irb(main):002:0> while s = STDIN.gets > irb(main):003:1>  sml += s > irb(main):004:1> end > 1 > 2 > 3 > => nil > irb(main):005:0> sml > => "1\n2\n3\n" Also, there are much easier ways to read the complete input than to use #gets: 13:46:50 $ seq 1 3 | ruby19 -e 'p STDIN.read' "1\n2\n3\n" 13:46:57 $ seq 1 3 | ruby19 -e 'STDIN.each_line {|l| p l}' "1\n" "2\n" "3\n" 13:47:50 $ Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/