From: Dave Baldwin Date: 2010-04-29T00:51:30+09:00 Subject: Re: Use of STDOUT.flush after puts On 28 Apr 2010, at 16:44, Alex DeCaria wrote: > I've seen several examples on this forum where folks have used > STDOUT.flush after printing a query to a terminal. For example: > > puts "Delete indicated item [yes, no]" > STDOUT.flush > response = gets.chomp > > What is the purpose of the 'STDOUT.flush', and is it always necessary to > use it? What are the possible problems if it isn't used? It forces the output to appear immediately, otherwise it may be held in a buffer for some indeterminate time, usually until enough output has accumulated to make it worth while to commit to the terminal, however as you are waiting for input this threshold will never be reached. Dave.