我想像这样运行这段代码
count = Hash.new(0)
while line = gets
words = line.split
words.each do |word|
count[word] += 1
end
end
count.sort{|a, b|
a[1] <=> b[1]
}.each do |key, value|
print "#{key}: #{value}\n"
end
但我不知道如何打破。击中Command+C返回
word_count.rb:3:in `gets': Interrupt
from word_count.rb:3:in `gets'
from word_count.rb:3:in `<main>'
如何修复此代码?