From: Stefan Lang Date: 2005-11-05T01:37:40+09:00 Subject: Re: Class and Mixin with same method name problem On Friday 04 November 2005 17:32, petermichaux@yahoo.com wrote: > Hi, > > I'm trying to call a modual method from a class method with the > same name. The code I tried and error are below. I think my > "Debug.whoAmI?" line is the problem. What is the correct syntax to > call the moduals method? > > Thanks, > Peter > > ==== CODE === > > module Debug > def whoAmI? > "#{self.class.name}" > end > end > > class EightTrack > include Debug > def whoAmI? > Debug.whoAmI? > end > end > > et = EightTrack.new > > p et.whoAmI? > > > === OUTPUT ERROR === > > peter$ ruby mixin.rb > mixin.rb:10:in `whoAmI?': undefined method `whoAmI?' for > Debug:Module (NoMethodError) > from mixin.rb:16 Try this: ---------------------- module Debug � def whoAmI? � � "#{self.class.name}" � end end class EightTrack � include Debug end et = EightTrack.new p et.whoAmI? ---------------------- Regards, Stefan