るりまサーチ

最速Rubyリファレンスマニュアル検索!
22件ヒット [1-22件を表示] (0.082秒)
トップページ > クエリ:-[x] > クエリ:terminate[x] > クエリ:exit[x] > クエリ:at_exit[x]

別のキーワード

  1. _builtin exit
  2. irb irb_at_exit
  3. irb irb_exit
  4. thread exit
  5. monitor exit

種類

ライブラリ

モジュール

検索結果

Kernel.#at_exit { ... } -> Proc (24422.0)

与えられたブロックをインタプリタ終了時に実行します。

...クをインタプリタ終了時に実行します。

at_exit
がメソッドである点を除けば、END ブロックによる終了
処理の登録と同等です。登録した処理を取り消すことはできません。
spec/terminateも参照してください。

@return 登録した処...
...Proc オブジェクトで返します。

//emlist[例][ruby]{
3.times do |i|
at_exit
{puts "at_exit#{i}"}
end
END{puts "END"}
at_exit
{puts "at_exit"}
puts "main_end"

#=> main_end
# at_exit
# END
# at_exit2
# at_exit1
# at_exit0
//}

@see d:spec/control#END,Kernel.#exit!,Kernel.#fork...

制御構造 (72.0)

制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END

...ます。

//emlist[][ruby]{
def iter
# (a)
# :
# (b)
yield
# (c)
# :
# (d)
end
iter { redo } # -> (b) へ飛ぶ
iter { next } # -> (c) へ飛ぶ
iter { break } # -> (d) へ飛ぶ
//}

(a) は、厳密には引数評価から始まります。(b) はブロック実行の直前...
...rror_type が省略された時は StandardError のサブクラスであ
る全ての例外を捕捉します。Rubyの組み込み例外は(SystemExit
Interrupt のような脱出を目的としたものを除いて)
StandardError のサブクラスです。

例外クラスのクラス階層...
...ロックで指定した文はインタ
プリタが終了する時に実行されます。Ruby の終了時処理について詳しくは
spec/terminateを参照してください。

複数の END ブロックを登録した場合は、登録したときと逆の順序で実
行されます。

//...