C
coderrr
Hi Matz,
I recently posted a Ruby 1.9 wishlist (http://groups.google.com/group/
ruby-talk-google/browse_thread/thread/d771ffa9fe10b811/
c8b5b0b02bd1e2d4) and the #1 item was to have rescue/else/ensure
available in all blocks w/o the need for begin/end. It turned out to
be the one thing that everyone agreed on. I think anyone who has done
a real project in Ruby has run into this.
Is there any way you can get this in 1.9?
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
Is so much nicer than this:
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
It would make all our lives better! :]
- steve
http://coderrr.wordpress.com
I recently posted a Ruby 1.9 wishlist (http://groups.google.com/group/
ruby-talk-google/browse_thread/thread/d771ffa9fe10b811/
c8b5b0b02bd1e2d4) and the #1 item was to have rescue/else/ensure
available in all blocks w/o the need for begin/end. It turned out to
be the one thing that everyone agreed on. I think anyone who has done
a real project in Ruby has run into this.
Is there any way you can get this in 1.9?
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
Is so much nicer than this:
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
It would make all our lives better! :]
- steve
http://coderrr.wordpress.com