るりまサーチ

最速Rubyリファレンスマニュアル検索!
41件ヒット [1-41件を表示] (0.047秒)

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

モジュール

キーワード

検索結果

Kernel.#throw(tag, value = nil) -> () (26135.0)

Kernel.#catchとの組み合わせで大域脱出を行います。 throw は同じ tag を指定した catch のブロックの終わりまでジャンプします。

...Kernel.#catchとの組み合わせで大域脱出を行います。 throw
は同じ tag を指定した catch のブロックの終わりまでジャンプします。

throw
は探索時に呼び出しスタックをさかのぼるので、
ジャンプ先は同じメソッド内にあるとは限...
...rgumentError 同じ tag で待っている catch が存在しない場合に発生します。

//emlist[例][ruby]{
def foo
throw
:exit, 25
end

ret = catch(:exit) do
begin

foo
some_process() # 絶対に実行されない
10
ensure
puts "ensure"
end
end
puts ret
#=> ensur...
...aram value catch の戻り値になります。
@raise UncaughtThrowError 同じ tag で待っている catch が存在しない場合に発生します。

//emlist[例][ruby]{
def foo
throw
:exit, 25
end

ret = catch(:exit) do
begin

foo
some_process() # 絶対に実行されない...

UncaughtThrowError#tag -> object (11028.0)

Kernel.#throw に指定した tag を返します。

...Kernel.#throw に指定した tag を返します。

//emlist[例:][ruby]{
def do_complicated_things
throw
:uncaught_label
end

begin

do_complicated_things
rescue UncaughtThrowError => ex
p ex.tag # => ":uncaught_label"
end
//}...

UncaughtThrowError#value -> object (11028.0)

Kernel.#throw に指定した value を返します。

...Kernel.#throw に指定した value を返します。

//emlist[例][ruby]{
def do_complicated_things
throw
:uncaught_label, "uncaught_value"
end

begin

do_complicated_things
rescue UncaughtThrowError => ex
p ex.value # => "uncaught_value"
end
//}...

UncaughtThrowError#to_s -> String (11018.0)

self を tag を含む文字列表現にして返します。

...self を tag を含む文字列表現にして返します。

//emlist[例][ruby]{
def do_complicated_things
throw
:uncaught_label
end

begin

do_complicated_things
rescue UncaughtThrowError => ex
p ex.to_s # => "uncaught throw :uncaught_label"
end
//}...