I tried running this simple code:
puts 4 i = gets puts i
It "works", but the console asks for a string, and then prints 4andi
4
i
Add a call flushto gets:
flush
gets
$stdout.flush
Instead of an explicit call $stdout.flush:
$stdout.sync = true
, ruby 1.8.7, 1.9.2 ree. ?
? . bash:)
, . , "" , , . , .
, , ?
, , : , STDIN STDERR. .
STDIN
STDERR
if you want to make sure that the text is displayed before something happens (as in this example), use the "flush" command, as Yossi suggests.