From: James Coglan Date: 2009-03-20T19:27:50+09:00 Subject: Re: nested methods --001636c5b3873b165804658a6850 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 2009/3/20 7stud -- > Hi, > > This example is from pickaxe2(I can't find the page): > > def toggle > > def toggle > puts "subsequent" > end > > puts "first" > end > > toggle > toggle > toggle > > --output:-- > first > subsequent > subsequent > > > Can someone explain why the nested method hides the outer method? The first call redefines toggle on the current object (which here seems to be the global main object) and then returns "first". After this, toggle has been replaced by the inner method so it returns "subsequent" for all further calls. -- James Coglan http://github.com/jcoglan --001636c5b3873b165804658a6850--