On Sun, 9 Dec 2001, Jim Freeze wrote:

> On Sun, 9 Dec 2001, David Alan Black wrote:
>
> > > module M
> > >  C = 2
> > >  def c
> > >   puts C
> > >  end
> > > end
> > > class A; end
> > > a=A.new
> > > a.extend M
> > > a.c # => 2
> >
> > Isn't it just that method c is defined in a context where C is in
> > scope?
>
> If it is just a scoping problem, then when why can't you do:
> a::C ?
> or
> a::M::C ?

Hmmmm...

Add this test:

  class << a
    puts C          # 2
  end

OK, so extending a is like:

  class << a
    # put code from module M here
  end

across the board?  (i.e., not just instance methods, which is what I
had thought)


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav