るりまサーチ

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

別のキーワード

  1. kernel throw
  2. _builtin throw
  3. minitest/spec must_throw
  4. throw
  5. rb_throw

モジュール

検索結果

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

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

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

throw
は探索時に呼び出しスタックをさかのぼるので、
ジャンプ先は同じメソッド内にあるとは限...
...意味です。

@
param tag catch の引数に対応する任意のオブジェクトです。
@
param value catch の戻り値になります。
@
raise ArgumentError 同じ 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
#=> ensure
# 25
//}

@
see Kernel.#catch...
...味です。

@
param tag catch の引数に対応する任意のオブジェクトです。
@
param value catch の戻り値になります。
@
raise UncaughtThrowError 同じ tag で待っている catch が存在しない場合に発生します。

//emlist[例][ruby]{
def foo
throw
:exit, 25
en...
...d

ret = catch(:exit) do
begin
foo
some_process() # 絶対に実行されない
10
ensure
puts "ensure"
end
end
puts ret
#=> ensure
# 25
//}

@
see Kernel.#catch...

Kernel.#catch {|tag| .... } -> object (66.0)

Kernel.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

...Kernel.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

ブロックの実行中に tag と同一のオブジェクトを引数とする Kernel.#throw が行われた
場合は、その throw の第二引数を戻り値として、ブロック...
...す。

@
param tag タグとなる任意のオブジェクトです。
@
return ブロックの返り値か、対応するthrowの第二引数を返り値として返します。

//emlist[例][ruby]{
result = catch do |tag|
for i in 1..2
for j in 1..2
for k in 1..2
throw
tag, k...
...end
end
end
end

p result #=> 1
//}

@
see Kernel.#throw...

Kernel.#catch(tag) {|tag| .... } -> object (66.0)

Kernel.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

...Kernel.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

ブロックの実行中に tag と同一のオブジェクトを引数とする Kernel.#throw が行われた
場合は、その throw の第二引数を戻り値として、ブロック...
...す。

@
param tag タグとなる任意のオブジェクトです。
@
return ブロックの返り値か、対応するthrowの第二引数を返り値として返します。

//emlist[例][ruby]{
result = catch do |tag|
for i in 1..2
for j in 1..2
for k in 1..2
throw
tag, k...
...end
end
end
end

p result #=> 1
//}

@
see Kernel.#throw...