Really thanks to the quick response, but it seems that the two ways of
definitions are not really equivalent. Just did an experiment.
If I say
module A
def self.a
p 'a'
end
end
class C
include A
end
> C.a
NoMethodError: undefined method `a' for C:Class
> c = C.new
> c.a
NoMethodError: undefined method `a' for #<C:0x7e478>
While if I changed the definition of module A to
module A
extend self
def a
p 'a'
end
end
...
> C.a
NoMethodError: undefined method `a' for C:Class
> c = C.new
> c.a
"a"
Anyone can explain this?
Cheers,
Donald
--
Posted via http://www.ruby-forum.com/.