How would you parse the difference whether the raise applies to the whole 
block, or just the previous statement?

David Vallner

D Nede•™a 12 FebruŠ” 2006 21:43 Daniel Nugent napý‘al:
> Is
>
> foo.each {|o|
>   raise "Oh noes, it's number 2!" if o == 2
> rescue Exception => e
>     puts e.to_s
> }
>
> really that hideous?
>
> On 2/12/06, David Vallner <david / vallner.net> wrote:
> > D Nede•™a 12 FebruŠ” 2006 20:39 Mark Volkmann napý‘al:
> > > On 2/12/06, Lou Vanek <vanek / acd.net> 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