クラス定義の中のself
クラスメソッドの定義でself.メソッド名と書ける理由もよくわかります。selfは実際にそのクラスなのですね。
class Rubyco def self.hello puts "Hello!" end def Rubyco.goodbye puts "Bye!" end end Rubyco.hello #=> Hello! Rubyco.goodbye #=> Bye!
クラスメソッドの定義でself.メソッド名と書ける理由もよくわかります。selfは実際にそのクラスなのですね。
class Rubyco def self.hello puts "Hello!" end def Rubyco.goodbye puts "Bye!" end end Rubyco.hello #=> Hello! Rubyco.goodbye #=> Bye!