Z
Zhenning Guan
we can define a instance method in lots way.
mostly, I saw people define like this:
1.
class A
def self.class_method
#some code here....
end
end
2.
class A
class << self
def class_method
#some code here....
end
end
end
==
the question confused me is what's the advantage of doing this in 2?
they'are different? which is your choose?
mostly, I saw people define like this:
1.
class A
def self.class_method
#some code here....
end
end
2.
class A
class << self
def class_method
#some code here....
end
end
end
==
the question confused me is what's the advantage of doing this in 2?
they'are different? which is your choose?