<分区>
Possible Duplicate:
What is the difference between include and extend in Ruby?
给定:
module my_module
def foo
...
end
end
问题一
有什么区别:
class A
include my_module
end
和
class A
extend my_module
end
问题二
将 foo
视为实例方法还是类方法?
换句话说,这是否等同于:
class A
def foo
...
end
end
或:
class A
def self.foo
...
end
end
?