Yukihiro Matsumoto
5/15/2008 11:17:00 PM
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 <coderrr.contact@gmail.com> 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.