From: Mark Date: 2001-09-11T21:25:07+09:00 Subject: [ruby-talk:21107] Re: nested method definition!!! Mark wrote: > I keep getting a "nested method definition" error. Although I have > failed to find the documentation for this specific error, I presume it's > when you do the following: > def foo(val1) > def bar(val2) > end > end > > The strange this is, I'm not doing anything like this. Maybe something > in Ruby is broken. I have looked over my code so many times (and it's > only 190 lines), and I can't see a problem. > I'm using 1.6.4 on Linux, everything else works fine. > > Please let me know exactly what might cause a "nested method definition > error". Then I'll check my code. If I'm more sure that what I'm doing is > right, I'll go ahead and post the code here and perhaps fill out a bug > report. > > -thanks > mark Ok, HERE is a simple example of what ruby does not like: class Example def method1(val1, val2) if val1 if val2 puts "both are true" end else if not val2 if not val 1 puts "both are false" end end end #apparently Ruby expects to see ANOTHER "end" here, before the next method. Why? def copy_of_method1(val1, val2) if val1 if val2 puts "both are true" end else if not val2 if not val 1 puts "both are false" end end end end #end of class Does this seem right???