本文簡要介紹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類。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。