[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

puts gets

Lloyd Linklater

10/29/2007 2:02:00 AM

I write this:


puts "foo"
some_var = gets

I expect the foo to show up before the gets occurs but it does not. Any
ideas?
--
Posted via http://www.ruby-....

2 Answers

Alex Gutteridge

10/29/2007 3:06:00 AM

0

On 29 Oct 2007, at 11:01, Lloyd Linklater wrote:

> I write this:
>
>
> puts "foo"
> some_var = gets
>
> I expect the foo to show up before the gets occurs but it does
> not. Any
> ideas?

The puts maybe buffered. Does this work as you expect:

$stdout.sync = true
puts "foo"
some_var = gets

Alex Gutteridge

Bioinformatics Center
Kyoto University



Liang He

10/29/2007 10:05:00 AM

0

Lloyd Linklater wrote:
> I write this:
>
>
> puts "foo"
> some_var = gets
>
> I expect the foo to show up before the gets occurs but it does not. Any
> ideas?

Or you could manually flush the buffer:
puts "foo"
STDOUT.flush
some_var = gets
--
Posted via http://www.ruby-....