From: Daniel Nugent Date: 2006-02-13T05:43:57+09:00 Subject: Re: Rescuing blocks? Is foo.each {|o| raise "Oh noes, it's number 2!" if o == 2rescue Exception => e puts e.to_s} really that hideous? On 2/12/06, David Vallner wrote:> D�a Nede�a 12 Febru�r 2006 20:39 Mark Volkmann nap�sal:> > On 2/12/06, Lou Vanek wrote:> > > this works,> > >> > > foo = [1, 2, 3]> > >> > > foo.each do |o|> > > begin> > > raise "Oh noes, it's number 2!" if o == 2> > > rescue Exception => e> > > puts e.to_s> > > end> > > end> >> > Sure it works, but Daniel wants to reduce the syntax a bit AND exit> > the loop if an exception is raised without having to specify that. I> > like his suggestion.> >> > --> > R. Mark Volkmann> > Partner, Object Computing, Inc.>> It would cause a little inconsistency with the curly brace form of blocks.> Either the rescue clause would have to work only for the do / end form, or> we'd be mixing braces and keywords in a single construct, which I couldn't> bear to look at.>> David Vallner>> ---Dan Nugent