るりまサーチ

最速Rubyリファレンスマニュアル検索!
18件ヒット [1-18件を表示] (0.179秒)
トップページ > クエリ:-[x] > クエリ:r[x] > 種類:特異メソッド[x] > クラス:Proc[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

検索結果

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

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

...@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。

//emlist[][ruby]{
pr = Proc.new {|arg| p arg }
pr.call(1) # => 1
//}

//emlist[][ruby]{
Proc
.new # => -e:1:in `new': tried to create Proc object without a block (ArgumentError)
//}

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

Proc.new -> Proc (3202.0)

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

...ックを指定しない場合、Ruby 2.7 では
$VERBOSE = true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生し...
... Proc オブジェクトとして生成して返します。

ただし、ブロックを指定しない呼び出しは推奨されていません。呼び出し元のメソッドで指定されたブロック
を得たい場合は明示的に & 引数でうけるべきです。

@raise ArgumentErro...
...r スタック上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end
foo {|arg| p arg }
# => 1
//}

これは以下と同じです。

//emlist[例][ruby]{
def foo
yield(1)
end
f...

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

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

...ックを指定しない場合、Ruby 2.7 では
$VERBOSE = true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生し...
... Proc オブジェクトとして生成して返します。

ただし、ブロックを指定しない呼び出しは推奨されていません。呼び出し元のメソッドで指定されたブロック
を得たい場合は明示的に & 引数でうけるべきです。

@raise ArgumentErro...
...r スタック上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end
foo {|arg| p arg }
# => 1
//}

これは以下と同じです。

//emlist[例][ruby]{
def foo
yield(1)
end
f...