るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

キーワード

検索結果

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

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

...t[][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, method) -> Symbol (27114.0)

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

...t[][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!"
//}...

NEWS for Ruby 2.1.0 (78.0)

NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...すためにキーワード引数 `exception: false` を受け付けるようになりました

* Kernel
* 追加: Kernel#singleton_method(Object#singleton_method)

* Module
* 追加: Module#using, which activates refinements of the specified module only
in the current class or mo...
...vate"
def foo
end
end
//}

* Object#untrusted?,Object#untrust,Object#trust
* これらのメソッドは非推奨になりました。$VERBOSE が true のときは警告を表示します。
Object
#tainted?,Object#taint,Object#untaint とそれぞれ同じ動作です。...
...ます。
The ancestors of a singleton class now include singleton classes,
in particular itself.

* Module#define_method Object#define_singleton_method
* 定義したメソッドの名前をシンボルで返すようになりました。メソッドオブジェクトではあり...

NEWS for Ruby 2.3.0 (30.0)

NEWS for Ruby 2.3.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...位置を表示します。
11725

* safe navigation operator (ぼっち演算子):
* object&.foo という形式のメソッド呼び出し形式が追加されました。これは object が nil でないときにメソッド foo を呼び出します。
Active Support の try!...
...不完全な文字があると例外が発生するようになりました。
11444

* Module
* Module#define_method と Object#define_singleton_method
メソッド本体(Procオブジェクト、Methodオブジェクト、またはブロック )が必須になりました。...
...* nkf
* nkf 2.1.4 をマージしました。

* ObjectSpace (objspace)
* ObjectSpace.#count_symbols を追加。
* ObjectSpace.#count_imemo_objects を追加。
* ObjectSpace.#internal_class_of を追加。
* ObjectSpace.#internal_super_of を追加。

* OpenSSL
* O...