るりまサーチ

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

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. zlib end

ライブラリ

検索結果

Proc.new -> Proc (20.0)

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

...OSE = 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)
が発生します。

ブロックを指定しなければ、こ...
...出しを行ったときに発生します。

//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end

foo {|arg| p arg }
# => 1
//}

これは以下と同じです。

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

foo {|arg| p arg }
# => 1
//}

呼び出し元のメソッドがブロックを...
...entError が発生します。

//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 が定義されていれば
オブジェクト...

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

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

...OSE = 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)
が発生します。

ブロックを指定しなければ、こ...
...出しを行ったときに発生します。

//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end

foo {|arg| p arg }
# => 1
//}

これは以下と同じです。

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

foo {|arg| p arg }
# => 1
//}

呼び出し元のメソッドがブロックを...
...entError が発生します。

//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 が定義されていれば
オブジェクト...