From: uncutstone wu Date: 2006-05-19T01:26:09+09:00 Subject: Re: Rescue clauses on do/end blocks? uncutstone wu wrote: > Ross Bamford wrote: >> On Thu, 2006-05-18 at 23:55 +0900, Daniel Schierbeck wrote: >>> I know this has been on the table before, but I really see no reason not >>> to allow do/end blocks to have rescue clauses on them, i.e. >>> >>> foo do >>> bar >>> rescue >>> baz >>> end >> >> Just playing Devil's Advocate, what'd happen with this: >> >> File.open('somefile') do |f| >> puts f.read >> end rescue puts "Can't open" >> >> ? > > What if rescue has more than one sentence? It seems not a good idea. > But I agree with Daniel Schierbeck's proposal. I think the syntax would be changed as below: File.open('somefile') do |f| puts f.read rescue puts "Can't open" end -- Posted via http://www.ruby-forum.com/.