Jacob Fugal wrote:
> On 7/18/06, transfire / gmail.com <transfire / gmail.com> wrote:
> >   class C
> >     def r ; "r" ; end
> >   end
> >
> >   module M
> >     def r
> >       #return '{' + super + '}'
> >       target = lambda{ super }
> >       b( target )
> >     end
> >     def b( target )
> >       '{' + target.call + '}'
> >     end
> >   end
> >
> >   module N
> >     def r
> >       target = lambda{ super }
> >       b( target )
> >     end
> >     def b( target )
> >       '[' + target.call + ']'
> >     end
> >   end
> >
> >   class D < C
> >     include M
> >     include N
> >   end
> >
> >   d = D.new
> >   p d.r  #=> "[[r]]"
> >
> > The result should be "[{r}]". Notice the remarked line I left in there,
> > if you unremark that line it works fine. So what going on? What can I
> > do to fix this?
>
> Looking at this, I don't think there's anything wrong with you're
> super at all, but rather, which b is being called. M#b and N#b collide
> when they're both included and you're losing your M#b altogether. If
> you rename so that those methods are different, you can see it
> working:
>
>   $ cat test.rb
>   class C
>     def r ; "r" ; end
>   end
>
>   module M
>     def r
>       #return '{' + super + '}'
>       target = lambda{ super }
>       b( target )
>     end
>     def b( target )
>       '{' + target.call + '}'
>     end
>   end
>
>   module N
>     def r
>       target = lambda{ super }
>       q( target ) # note the changed method name here
>     end
>     def q( target ) # and here
>       '[' + target.call + ']'
>     end
>   end
>
>   class D < C
>     include M
>     include N
>   end
>
>   d = D.new
>   p d.r  #=> "[{r}]"
>
>   $ ruby test.rb
>   "[{r}]"
>
> Jacob Fugal

Ah! Of course, Thank you. Unfortuantely NOW I need class local methods!
:(

T.