Hi --

On Mon, 2 Oct 2006, MonkeeSage wrote:

> Trans wrote:
>> Produces:
>>
>>   false
>
> That's correct. In that case self is an *instance* of Object...
>
> module Test
>  def test
>    puts 'hi'
>  end
> end
> class << self
>  include Test
> end
> test
>
> ...but Module#included tells you the module or class of the including
> scope; it doesn't pass the instance itself.

Yes it does: the instance itself *is* a Module (or Class) :-)  There's
no translation or looking up necessary:

   class C
     include M   # the method "include" is called on the object C
   end

The top level is a bit anomalous: 'self' is not a Module or Class, but
it does some proxying for Object.  So if you do:

   include M

at the top level, it's as if you'd done:

   class Object
     include M
   end


David

-- 
                   David A. Black | dblack / wobblini.net
Author of "Ruby for Rails"   [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB's Weblog)        [2] | Co-director, Ruby Central, Inc.   [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com    | [4] http://www.rubycentral.org