>> > 'else' only runs if no exception was raised.
>> 
>> Yes, else only runs if no exception was raised; and it will run BEFORE the
>> ensure block. BUT unlike code in the main code block (begin..rescue) it
>> CAN raise unchecked exceptions.

> Do you feel like that's an implementation quirk of Ruby, or something
> deliberate?
> In other words, this code..
>
> @count = 0
> begin
> @count += 1
> raise RuntimeError.new("Ha Ha!") if @count == 1
> rescue Exception
> puts "hello from rescue"
> retry
> else
> puts "else"
> raise RuntimeError.new("Boom") if @count == 2
> end
>
> Is it part of ruby's 'spec' that the 'rescue' block only be executed
> once, in the above code?

It sounds like it is deliberate - otherwise, why introducing the else 
block at all? That's the only thing that else does.

Also, when you say "rescue block only be executed once in the above code", 
if you took the first raise ("Ha Ha!") away - it would not trigger the 
rescue at all.  This is apparently, why 'else' is positioned AFTER 
'rescue' in the execution order. Once you're past the rescue block, there 
is no rescue to jump back to. i.e. if you want to rescue from an exception 
in the else block, you'd need to do it in a separate begin..rescue..end 
block wrapping around the begin..rescue..else..end construct you are 
using.



Benedikt




   ALLIANCE, n.  In international politics, the union of two thieves who
     have their hands so deeply inserted in each other's pockets that
     they cannot separately plunder a third.
 			(Ambrose Bierce, The Devil's Dictionary)