るりまサーチ

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

別のキーワード

  1. objectspace each_object
  2. _builtin each_object
  3. object send
  4. object to_enum
  5. object enum_for

ライブラリ

クラス

検索結果

Fiber.yield(*arg = nil) -> object (18315.0)

現在のファイバーの親にコンテキストを切り替えます。

... yield メソッドは返します。

@param arg 現在のファイバーの親に渡したいオブジェクトを指定します。

@raise FiberError Fiber でのルートファイバーで呼ばれた場合に発生します。


//emlist[例:][ruby]{
a = nil
f = Fiber.new do
a = Fiber.yield(...
...)
end

f.resume()
f.resume(:foo)

p a #=> :foo
//}...

Proc.new -> Proc (119.0)

ブロックをコンテキストとともにオブジェクト化して返します。

...pturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しなければ、このメソッドを呼び出したメソッドが
ブロック...
...rg }
# => 1
//}

これは以下と同じです。

//emlist[例][ruby]{
def foo
yield
(1)
end
foo {|arg| p arg }
# => 1
//}

呼び出し元のメソッドがブロックを伴わなければ、例外
ArgumentError が発生します。

//emlist[例][ruby]{
def foo
Proc.new
end
foo
# => -:2:in...
...`new': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}

Proc.new は、Proc#initialize が定義されていれば
オブジェクトの初期化のためにこれを呼び出します。このことを
除けば、Kernel.#proc...

Proc.new { ... } -> Proc (119.0)

ブロックをコンテキストとともにオブジェクト化して返します。

...pturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しなければ、このメソッドを呼び出したメソッドが
ブロック...
...rg }
# => 1
//}

これは以下と同じです。

//emlist[例][ruby]{
def foo
yield
(1)
end
foo {|arg| p arg }
# => 1
//}

呼び出し元のメソッドがブロックを伴わなければ、例外
ArgumentError が発生します。

//emlist[例][ruby]{
def foo
Proc.new
end
foo
# => -:2:in...
...`new': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}

Proc.new は、Proc#initialize が定義されていれば
オブジェクトの初期化のためにこれを呼び出します。このことを
除けば、Kernel.#proc...