From: Dave Howell Date: 2006-04-19T14:20:39+09:00 Subject: Re: Nested scopes On Apr 18, 2006, at 18:50, dblack@wobblini.net wrote: > Hi -- > > On Wed, 19 Apr 2006, Yoann Guillot wrote: > >> Hi, >> >> I just discovered a behavior of ruby that seems strange to me. Me too. >> Shouldn't ruby walk the nesting stack when it doesn't find a method >> name ? > > No; it should walk the method lookup path. Fine. Why doesn't the method lookup path include the scope of the progenitor, or provide access to it? Your answer merely begs the question. Yoann, I ran into the same rather exasperating behavior. Here's how I solved it: module Foo def self.bar puts "bar!" end bar # works class Baz def initialize(parent) @parentClass = parent end def something # bar # doesn't work # self.bar # doesn't work Foo.bar # need to know the module name @parentClass.bar # works, doesn't need module name hard-coded. end end my_baz = Baz.new(self) my_baz.something # no error end