るりまサーチ (Ruby 3.1)

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

別のキーワード

  1. object define_singleton_method
  2. _builtin define_singleton_method
  3. singleton clone
  4. singleton dup
  5. singleton instance

ライブラリ

検索結果

Object#singleton_method(name) -> Method (54361.0)

オブジェクトの特異メソッド name をオブジェクト化した Method オブ ジェクトを返します。

...o.new(99)
def k.hi
"Hi, @iv = #{@iv}"
end
m = k.singleton_method(:hi) # => #<Method: #<Demo:0xf8b0c3c4 @iv=99>.hi>
m.call #=> "Hi, @iv = 99"
m = k.singleton_method(:hello) # => NameError
//}

@see Module#instance_method, Method, BasicObject#__send__, Object#send, Kernel.#eval, Object#method...