From: Tim Bates Date: 2004-03-04T12:45:33+09:00 Subject: Re: Why do inner methods count in outer scope? Charles Comstock wrote: > Out of curiosity, why don't you just use an eval to change function > definitions? I do. Watch: def mk_func(:name) eval <<-EOF def #{name}(foo) puts foo end EOF end Even when using eval, you've got to use a def keyword somewhere to define a method. As far as I'm concerned, the example above should be equivalent to def mk_func2 def bar(foo) puts foo end end With the exception of course that the name of the function is not dynamic, which is why we use eval in the first place. The point I'm making, however, is that the scoping rules for the inner function in both examples should be equivalent, and that without the scoping being as it is I would be unable to dynamically define methods in this manner. Tim. -- Tim Bates tim@bates.id.au