Hi --

On Tue, 11 Jul 2006, Russell Fulton wrote:

> unknown wrote:
>> Hi --
>>>
>> It should.  Try again :-)
>>
>>
> Thanks David, I thought it  should...
>
> It would appear that the problem is related to how the control is passed
> between the classes.  I am instantiating Inner from Outer...
>
> I have reduced my program to its essentials:
>
> module Parser
>  def lineno
>    10
>  end
> end
>
>
> class Outer
>  include Parser
>
>  def initialize ()

The empty parens are definitely *not* part of the prgram's essentials
:-)  (You weren't doing them before.  Is it something I said? :-)

>    puts lineno    # prints 10
>    x = Inner.new
>  end
>
>  class Inner
>
>  def initializ

The 'e' on the end of initialize *is*, however, essential :-)

>    puts lineno # gives error

You still haven't included Parser in Inner.  If you don't, instance of
Inner won't have Parser's methods.  (See my example again.)

>  end
> end

You're missing an end here.

> Outer.new()

What it comes down to is that module inclusion is per class.  A nested
class is still a completely different class from the class it's nested
in, so you need to include the module in the inner class separately.


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