Is there some reason why it can't be made more elegant like it iscurrently for methods? Currently you can do this for methods:
def test  raiserescue  puts "Error"end
Farrel
On 3/7/06, Marcin Miel˝ˇki <lopexx / autograf.pl> wrote:> Farrel Lifson wrote:> > I've been playing around with rescue expressions and besides being put> > on functions they also seem to work when defining classes (useful for> > metaprogramming perhaps?)> >> > irb(main):001:0> class Test> > irb(main):002:1>   raise> > irb(main):003:1> rescue> > irb(main):004:1>   puts "Error"> > irb(main):005:1> ensure> > irb(main):006:1*   puts "Cleaned up"> > irb(main):007:1> end> > Error> > Cleaned up> >> > However, why can they not be applied to do end blocks?> >> > irb(main):016:0> [1,2,3].each do |num|> > irb(main):017:1*   num.upcase> > irb(main):018:1> rescue> > irb(main):019:1>   puts "Error"> > irb(main):020:1> ensure> > irb(main):021:1*   puts "Clened up"> > irb(main):022:1> end> > SyntaxError: compile error> > (irb):18: syntax error> > (irb):20: syntax error> >         from (irb):22> >> > Farrel> >> >>> rescue must be enclosed in begin/end>> [1,2,3].each do |num|>   begin #!>     num.upcase>   rescue>     puts "Error">   ensure>     puts "Clened up">   end> end>> lopex>>