在编写 Ruby 脚本时,有没有办法在脚本因键盘中断而停止之前指定要执行的命令CtrlC?
1 回答
            4        
        
		
在Ruby 文档中Interrupt找到它,对于那些感兴趣的人
begin
  puts "Press ctrl-C when you get bored"
  loop {}
rescue Interrupt => e
  puts "Note: You will typically use Signal.trap instead."
end
于 2012-12-13T02:26:01.553   回答