--1926193751-701745803-12463081678755
Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-701745803-1246308167=:18755"

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--1926193751-701745803-12463081678755
Content-Type: TEXT/PLAIN; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: 8BIT

Hi --

On Tue, 30 Jun 2009, Jg W Mittag wrote:

> Yossef Mendelssohn wrote:
>> On Jun 29, 2:35   Үî>> wrote:
>>> Since its related to 'rescue', I'll point out that you can also use >>> 'else' to indicate code that only gets executed if none of the rescue >>> clauses are (i.e., there is no exception). This is, of course, not >>> like 'ensure' with is executed regardless.
>> Really? This is the first I've heard of this, and it seems kind of
>> strange.
>>
>> Maybe I'm misunderstanding the point of the 'else' clause, but
>> wouldn't you put code that "only gets executed if none of the rescue
>> clauses are (i.e., there is no exception)" in the main body of what
>> you're adding rescues to? (viz. begin block, method definition)
>
> Counterexample:
>
> begin
>  puts "According to your theory, this shouldn't be evaluated, "
>  puts "but it will."
>  raise RuntimeError
> rescue
> else
>  puts "This, however, won't."
> end

I think Yossef is talking about a case where something like this:

   begin
     require 'something'
   rescue LoadError
     puts "Sorry"
   else
     m  omething.new
   end

could be done like this instead:

   begin
     require 'something'
     m  omething.new
   rescue LoadError
     puts "Sorry"
   end

There's another thread going in which I've stumbled through several
iterations of advice to someone about exactly this problem, and
essentially ended up with that last one. A great example of
cross-thread heterodyning :-)


David

-- 
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now available: The Well-Grounded Rubyist (http://manning.com/black2)
"Ruby 1.9: What You Need To Know" Envycasts with David A. Black
http://www.envycasts.com
--1926193751-701745803-12463081678755--
--1926193751-701745803-12463081678755--