From: dblack@... Date: 2006-02-22T00:39:01+09:00 Subject: Re: "exporting" module methods Hi -- On Wed, 22 Feb 2006, Mark Volkmann wrote: > On 2/21/06, dblack@wobblini.net wrote: > >> I don't think that's what Xavier wanted; I think he wanted C to be >> able to call M.croak. (Also, in your example, c doesn't respond to >> croak.) > > Wow! I have a fundamental misunderstanding of mixins apparently. I > see that you are correct. c doesn't respond to croak in the following > code. However, I don't understand why. Doesn't the include add > instance methods from the module M to the class C? > > module M > def self.croak > puts 'croak' > end > end > > class C > include M > end > > c = C.new > c.croak Yes, but croak isn't an instance method :-) (Note the "self." part.) David -- David A. Black (dblack@wobblini.net) Ruby Power and Light (http://www.rubypowerandlight.com) "Ruby for Rails" chapters now available from Manning Early Access Program! http://www.manning.com/books/black