From: Austin Ziegler Date: 2005-05-28T00:15:45+09:00 Subject: Re: Difference between 'def self. …' and module_function … On 5/27/05, Nikolai Weibull wrote:> I thought I new the difference between writing> module A> def self.a> ���> end> end> > and> module B> def a> ���> end> > module_function :a> end Module A defines only A.a. Module B defines B#a and B.a. B.a is a copyof B#a at the time of the call to module_function and B#a is madeprivate (according to the documentation). module A def self.a puts "#{self.inspect}.a" endend module B def a puts "#{self.inspect}.a" end module_function :aend A.methods(false) # -> [ "a" ]B.methods(false) # -> [ "a" ]B.instance_methods(false) # -> []B.private_instance_methods(false) # -> ["a"]A.a # -> A.aB.a # -> B.ao = Object.newo.extend(B)o.send(:b) # -> #.a Does that make it clearer? -austin-- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca