From: Yukihiro Matsumoto Date: 2008-05-16T08:16:35+09:00 Subject: Re: Matz: can we have rescue/else/ensure available in all blocks? Hi, In message "Re: Matz: can we have rescue/else/ensure available in all blocks?" on Fri, 16 May 2008 07:02:47 +0900, coderrr writes: |This (contrived example): | |pages.each do |page| | page.links.each do |link| | process link | rescue MalformedLinkError | @bad_links << link | end |rescue MalformedPageError | @bad_pages << page |end can be considered as pages.each do |page| begin page.links.each do |link| begin process link rescue MalformedLinkError @bad_links << link end end rescue MalformedPageError @bad_pages << page end end and begin pages.each do |page| begin page.links.each do |link| process link end rescue MalformedLinkError @bad_links << link end end rescue MalformedPageError @bad_pages << page end If it contains ensure, things are more complicated. Perhaps you would expect foo do break ensure puts "foo" end would print "foo" even when foo does not give control to the block. matz.