本文简要介绍ruby语言中 Interrupt类
的用法。
在收到中断信号时引发,通常是因为用户按下了Control-C(在大多数 posix 平台上)。因此,它是 SignalException
的子类。
begin
puts "Press ctrl-C when you get bored"
loop {}
rescue Interrupt => e
puts "Note: You will typically use Signal.trap instead."
end
产生:
Press ctrl-C when you get bored
then waits until it is interrupted with Control-C and then prints:
Note: You will typically use Signal.trap instead.
相关用法
- Ruby Integer.nobits?用法及代码示例
- Ruby Integer lcm()用法及代码示例
- Ruby Integer.self >=用法及代码示例
- Ruby Integer.self >>用法及代码示例
- Ruby Integer.next用法及代码示例
- Ruby Integer.self ** numeric用法及代码示例
- Ruby Integer integer?用法及代码示例
- Ruby Integer.truncate用法及代码示例
- Ruby Integer digits用法及代码示例
- Ruby Integer divmod()用法及代码示例
- Ruby Integer floor()用法及代码示例
- Ruby Integer.sqrt用法及代码示例
- Ruby Integer to_f用法及代码示例
- Ruby Integer to_s用法及代码示例
- Ruby Integer.bit_length用法及代码示例
- Ruby Integer times用法及代码示例
- Ruby Integer truncate()用法及代码示例
- Ruby Integer remainder()用法及代码示例
- Ruby Integer.floor用法及代码示例
- Ruby Integer.pred用法及代码示例
- Ruby Integer.gcd用法及代码示例
- Ruby Integer fdiv()用法及代码示例
- Ruby Integer bit_length用法及代码示例
- Ruby Integer pred()用法及代码示例
- Ruby Integer ceil用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 Interrupt类。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。