るりまサーチ

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

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. bigdecimal to_r
  5. fileutils cp_r

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 > >>

VALUE rb_catch(const char *tag, VALUE (*proc)(), VALUE data) (32246.0)

catch と同等の動作を実行します。

...
catch
と同等の動作を実行します。

まず proc に、yield された値と data を渡して実行します。
その途中で tag が throw されたら rb_catch 全体を終了します。

throw が発生した場合はその値を返します。
throw が発生しなかったとき...
...は proc の返り値を返します。

static VALUE
foo_yield(VALUE a, VALUE b)
{
r
eturn rb_yield(b);
}

static VALUE
foo_catch(VALUE obj)
{
r
eturn rb_catch("footag", foo_yield, INT2FIX(2));
}

static VALUE
foo_abort(VALUE obj)
{
r
eturn rb_throw("footag", Qn...
...il);
}

void
Init_foo(void)
{
VALUE Foo = rb_define_class("Foo", rb_cObject);
r
b_define_method(Foo, "catch", foo_catch, 0);
r
b_define_method(Foo, "abort", foo_abort, 0);
}...

static VALUE rb_f_catch(VALUE dmy, VALUE tag) (32200.0)

void rb_throw(const char *tag, VALUE val) (26122.0)

throw の実体。返り値を val として、 tag を catch したところまでジャンプします。

...throw の実体。返り値を val として、
tag を catch したところまでジャンプします。

r
b_catch も参照してください。...

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

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

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

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

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

//emlist[例][ruby]{
r
esult = 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 (21124.0)

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

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

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

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

//emlist[例][ruby]{
r
esult = 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...

絞り込み条件を変える

static void catch_timer(int sig) (12200.0)

UncaughtThrowError (12016.0)

Kernel.#throw に指定した tag に対して一致する Kernel.#catch が存在しない場合に発生します。

...Kernel.#throw に指定した tag に対して一致する
Kernel.#catch が存在しない場合に発生します。

throw "foo", "bar"
# => (例外発生) UncaughtThrowError: uncaught throw "foo"...

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

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

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

throw は探索時に呼び出しスタックをさかのぼるので、
ジャンプ先は同じメソッド内にあるとは限...
...し ensure節 が存在するならジャンプ前に実行します。

同じ tag で待っている catch が存在しない場合は、例外で
スレッドが終了します。

同じ tag であるとは Object#object_id が同じであるという意味です。

@param tag catch の引数...
...ェクトです。
@param value catch の戻り値になります。
@raise ArgumentError 同じ tag で待っている catch が存在しない場合に発生します。

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

r
et = catch(:exit) do
begin
foo
some_process() # 絶対に実...
...ェクトです。
@param value catch の戻り値になります。
@raise UncaughtThrowError 同じ tag で待っている catch が存在しない場合に発生します。

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

r
et = catch(:exit) do
begin
foo
some_process() # 絶対...

RubyVM::InstructionSequence.disasm(body) -> String (6118.0)

引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。

...した
R
ubyVM::InstructionSequence オブジェクトを人間が読める形式の文字
列に変換して返します。

@param body Proc、Method オブジェクトを指定します。

例1:Proc オブジェクトを指定した場合

# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM...
...::InstructionSequence.disasm(p)

出力:

== disasm: <RubyVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== catch table
| catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000
| catch type: next st: 0000 ed: 0012 sp: 0000 cont: 0012
|-----------------------------------------...
...-------------------------------
local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1] s1)
[ 2] num
0000 trace 1 ( 1)
0002 putobject 1
0004 putobject 2
0006 opt_plus <ic:1>
0008 dup
0009 s...
<< 1 2 > >>