クラスメソッドの呼び出しと、次の違いがあるかどうかに興味があります。
class Jt
class << self
def say_hello
puts "I want to say hello"
end
end
end
class Jt2
def self.say_hello
puts "2 want to say hello"
end
end
Jt.say_hello
Jt2.say_hello
それは単なるスタイルですか、それともルビーがこれらを処理する方法に違いはありますか? 私は常に後者を Rails のものに使用しますが、メタプログラミングや Rails のソース コードでは前者をよく見かけます。