From: Brian Candler Date: 2010-07-11T01:04:29+09:00 Subject: Re: what about allowing to specify, which end belongs to which start? Jan Lelis wrote: > Hi Ruby mailing list, > > I've recently come across a pretty common situation in Ruby: > > end > end > end > > After those parts, you often don't know, where exactly you have to > continue. You can always use comments, although I'd only usually do this for nested modules. e.g. module Foo module Bar class Baz .... end # class Baz end # module Bar end # module Foo Otherwise, I've never found it a problem, unless I've missed an 'end', or forgotten a 'do'. ruby 1.9 with -w flag has a neat feature where it will warn if the indentation is not as expected, thus making it much easier to find where the problem is. e.g. $ cat test.rb def foo puts "hello" 5.times # note missing "do" puts "world" end puts "goodbye" end $ ruby19 test.rb test.rb:7: syntax error, unexpected keyword_end, expecting $end $ ruby19 -w test.rb test.rb:5: warning: mismatched indentations at 'end' with 'def' at 1 test.rb:7: syntax error, unexpected keyword_end, expecting $end This shows that the 'end' at line 5 was associated with the 'def' at line 1, which helps localise the problem. It's a shame that ruby 1.8.7 doesn't have this feature, although you can keep a copy of ruby 1.9 lying around just for locating such problems (the parsing of the two languages is very similar, even though the semantics are very different) -- Posted via http://www.ruby-forum.com/.