类方法和单例方法是相同还是不同?这是一个例子.
class C
def self.classmethod
puts "class method #{self}"
end
end
C.classmethod # class method C
c = C.new
def c.singletonmethod
puts "instance method #{self}"
end
c.singletonmethod # instance method #<C:0x0000000118ed08>
Run Code Online (Sandbox Code Playgroud)