From: dblack@... Date: 2006-07-11T07:28:47+09:00 Subject: Re: problems with mixins Hi -- On Tue, 11 Jul 2006, Russell Fulton wrote: > Hi Folks, > I'm have some problems with mixin from a module that I have > written. > > Module Parser > > def thing > . > . > end > > end > > class Outer > include Parser > > def initialize > print thing # works > end > > class Inner > > def initialize > print thing # fails with undefined local variable or method > `thing' > end > end # of Inner > end # of Outer > > I've tried an include Parser in inner but that does not make any > difference It should. Try again :-) module Parser def thing "Thing" end end class Outer include Parser def initialize puts thing end class Inner include Parser def initialize puts thing end end end Outer::Inner.new # => Thing David -- http://www.rubypowerandlight.com => Ruby/Rails training & consultancy http://www.manning.com/black => RUBY FOR RAILS, the Ruby book for Rails developers http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log dblack@wobblini.net => me