From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2003-07-18T02:17:42+09:00 Subject: Re: What's the point? In article <20030717103702.A3418@freeze.org>, Jim Freeze wrote: >Hi > >I've known for some time that methods can be defined inside >methods, but I am still wondering what's the point. > > def fred > def x > puts "x" > end > x > end > Used to be you couldn't do that; apparently, it's new in 1.8. As to your other question about "why?" - Sometimes I used to do this in Perl to localize some functionality within a method (..errr, function or subroutine in Perl parlance). Usually this was in a sort of refactoring stage where I'd look at my sub and find that I had some duplicated code in it that I could collect into another sub-sub. BTW: It seems that whenever I look at Python code (which isn't too often) I see this being done. So I guess when something is possible it will get used. Phil