有人能解釋一下Ruby中這3個(顯然)相同的例子嗎?Ruby:在類中聲明方法的不同方法
代碼#1
class User < ActiveRecord::Base
def something
....
end
end
代碼#2
class User < ActiveRecord::Base
def User.something
....
end
end
代碼#3
class User < ActiveRecord::Base
def self.something
....
end
end
請參閱關於'class methods'的[this](http://www.railstips.org/blog/archives/2009/05/11/class-and-instance-methods-in-ruby/) '實例方法' – Anthony 2014-11-23 17:21:36