るりまサーチ

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

別のキーワード

  1. _builtin define_method
  2. irb/input-method gets
  3. irb/input-method new
  4. irb/input-method encoding
  5. irb/input-method readable_atfer_eof?

ライブラリ

クラス

検索結果

Object#define_singleton_method(symbol, method) -> Symbol (33441.0)

self に特異メソッド name を定義します。

...m method Proc、Method あるいは UnboundMethod
いずれかのインスタンスを指定します。

@return メソッド名を表す Symbol を返します。

//emlist[][ruby]{
class A
class << self
def class_name
to_s
end
end
end
A.define_singleton_method(...
...:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"

guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
guy.hello #=> "Bob: Hello there!"
//}...

Object#define_singleton_method(symbol) { ... } -> Symbol (33341.0)

self に特異メソッド name を定義します。

...m method Proc、Method あるいは UnboundMethod
いずれかのインスタンスを指定します。

@return メソッド名を表す Symbol を返します。

//emlist[][ruby]{
class A
class << self
def class_name
to_s
end
end
end
A.define_singleton_method(...
...:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"

guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
guy.hello #=> "Bob: Hello there!"
//}...