るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.028秒)
トップページ > クエリ:object[x] > クエリ:>[x] > クエリ:call[x] > 種類:クラス[x]

別のキーワード

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

ライブラリ

検索結果

Method (71.0)

Object#method によりオブジェクト化され たメソッドオブジェクトのクラスです。

...Object#method によりオブジェクト化され
たメソッドオブジェクトのクラスです。

メソッドの実体(名前でなく)とレシーバの組を封入します。
Proc オブジェクトと違ってコンテキストを保持しません。

=== Proc との差

Method...
...ドを Method オブジェクト化する。

//emlist[例][ruby]{
class
Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Foo.new.method(:foo)

p m # => #<Method: Foo#foo>
p m.call(1) # => "foo called with arg 1"
//}

名前のないメソッド(の代わり)が必...
...t[例][ruby]{
pr = Proc.new {|arg|
"proc called with arg #{arg}"
}

p pr # => #<Proc:0x401b1fcc>
p pr.call(1) # => "proc called with arg 1"
//}

Method オブジェクトが有用なのは以下のような場合。

//emlist[例][ruby]{
class
Foo
def foo() "foo" end
def bar() "b...