15
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rubyでクラスメソッドの定義方法色々

Last updated at Posted at 2012-03-16

今まではdef self.hogeって書いてたけど,class << self ...の方がまとまって見通しが良さそう.

class A
  def A.class_method_one; end

  def self.class_method_two; end

  class << A
    def class_method_three; end
  end

  class << self
    def class_method_four; end
  end
end

def A.class_method_five; end

class << A
  def class_method_six; end
end
15
15
3

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
15
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?