From: "Brian Schröder" Date: 2004-12-03T19:27:58+09:00 Subject: Re: nested defs, what if... On Fri, 3 Dec 2004 08:20:34 +0900 "trans. (T. Onoma)" wrote: > [snip] > Well, it's an idea, but I don't think a very good one. In general I don't > think this is useful, and would rather obfuscate code if actually used. I > think what would be more useful is if such methods were local methods, like > local variables: > > class A > def a > def b(x) > x + 1 > end > 10.times{ |i| print b(i) } > end > end > > o = A.new > o.b => NoMethodError > A.a => 12345678910 > o.b => NoMethodError > > This would allow for embedded subroutines --much more useful. > I tried this in fact while learning ruby, and was disappointed, that it did not work the way I expected. The last language before Ruby was Delphi (Object Pascal) where you can have nested subroutines. I think they are a lot clearer than having to flatten everything out. Regards, Brian -- Brian Schr�der http://www.brian-schroeder.de/