RosettaCodeData/Task/Keyboard-input-Flush-the-keyboard-buffer/Ruby/keyboard-input-flush-the-keyboard-buffer-4.rb
2023-07-01 13:44:08 -04:00

9 lines
226 B
Ruby

# Demonstration: discard input, then input a line from user.
puts 'Type anything for 2 seconds.'
sleep 2
$stdin.discard_input
print 'Enter a line? '
if line = $stdin.gets
then print 'Got line. ', line
else puts 'No line!'
end