LoginSignup
2
2

More than 5 years have passed since last update.

class method定義から考察するRubyの仕組み

Posted at

特異クラスとはとあるオブジェクトのために、用意されるクラスである。
ただ、Rubyにとっては、classもオブジェクトであるため、classメソッドを定義するためには
class(というオブジェクト)の特異クラスに対してmethodを定義する必要がある。

特異メソッドを定義する際に表記されるselfとは自分自身のクラス(オブジェクト)を指す。
"class << self" の表記は自分自身のクラス(オブジェクト)の特異クラスについて定義することを指す。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2