From: kwatch@... (kwatch) Date: 2002-05-10T10:42:29+09:00 Subject: Re: gets and eof? ts wrote in message news:<200205091356.g49DuF607972@moulon.inra.fr>... > > ruby use an active model (is EOF waiting at the stream) rather than a > passive model (is EOF has already met the stream) > > > Guy Decoux I tried another program. .============================ prog3.rb == loop do break if $stdin.eof? print "*** 'break if $stdin.eof?' done.\n" line = $stdin.gets print "*** 'line = $stdin.gets' done.\n" puts "<-- #{line}" print "*** 'puts <--\#{line}' done, continue loop.\n" end .======================================== .---------------------------------------- % ruby prog3.rb hoge *** 'break if $stdin.eof?' done. # Hmm? *** 'line = $stdin.gets' done. <-- hoge *** 'puts <--#{line}' done, continue loop. geji *** 'break if $stdin.eof?' done. # Hmm? *** 'line = $stdin.gets' done. <-- geji *** 'puts <--#{line}' done, continue loop. ^D % .---------------------------------------- .============================= prog4.rb == loop do line = $stdin.gets print "*** 'line = $stdin.gets' done.\n" break if $stdin.eof? print "*** 'break if $stdin.eof?' done.\n" puts "<-- #{line}" print "*** 'puts <--\#{line}' done, continue loop.\n" end .======================================== .---------------------------------------- % ruby prog4.rb hoge *** 'line = $stdin.gets' done. geji *** 'break if $stdin.eof?' done. # Oh! <-- hoge *** 'puts <--#{line}' done, continue loop. *** 'line = $stdin.gets' done. bake *** 'break if $stdin.eof?' done. # Oh! <-- geji *** 'puts <--#{line}' done, continue loop. *** 'line = $stdin.gets' done. ^D % .---------------------------------------- It shows that '$stdin.eof?' stops the progress. Is this what you mean, Guy? Regards, kwatch