Ruby Class Methods vs. Methods in Eigenclasses
问题 Are class methods and methods in the eigenclass (or metaclass) of that class just two ways to define one thing? Otherwise, what are the differences? class X # class method def self.a "a" end # eigenclass method class << self def b "b" end end end Do X.a and X.b behave differently in any way? I recognize that I can overwrite or alias class methods by opening the eigenclass: irb(main):031:0> class X; def self.a; "a"; end; end => nil irb(main):032:0> class X; class << self; alias_method :b, :a;