16 May 00:02
Matz: can we have rescue/else/ensure available in all blocks?
From: coderrr <coderrr.contact <at> gmail.com>
Subject: Matz: can we have rescue/else/ensure available in all blocks?
Newsgroups: gmane.comp.lang.ruby.general
Date: 2008-05-15 22:02:47 GMT
Subject: Matz: can we have rescue/else/ensure available in all blocks?
Newsgroups: gmane.comp.lang.ruby.general
Date: 2008-05-15 22:02:47 GMT
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
RSS Feed