# Re: reasons to use else inside rescue

**URL:** <https://www.ruby-forum.com/t/re-reasons-to-use-else-inside-rescue/75578>\
**Category:** Ruby\
**Created:** [March 2, 2006, 4:07am UTC](https://www.ruby-forum.com/t/re-reasons-to-use-else-inside-rescue/75578 "2006-03-02T04:07:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Dunn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@Christopher\_Dunn](https://www.ruby-forum.com/u/Christopher_Dunn)\
**Post date:** [March 2, 2006, 4:07am UTC](https://www.ruby-forum.com/t/re-reasons-to-use-else-inside-rescue/75578/1 "2006-03-02T04:07:13Z")

</div>

* * *

## I suppose a difference is that if “do\_more\_stuff” raises an exception, the first example can’t rescue it and the second might. Is that the only difference?

That’s exactly right. The else clause is for code which might issue  
exceptions that you would rather not trap.

Note that an “ensure” clause would occur even if an “else” clause  
raises an exception, so this:

begin  
do\_something  
rescue  
handle\_exception  
else  
do\_more\_stuff  
ensure  
definitely\_do\_this\_last  
end

without the “else”, would be written like this:

begin  
no\_errors = false  
begin  
do\_something  
no\_errors = true  
rescue  
handle\_exception  
do\_more\_stuff if no\_errors  
ensure  
definitely\_do\_this\_last  
end

Interestingly, Python does not allow except/else with finally. The  
reason? It was considered ambiguous to the reader. (In Python2.5, this  
constraint is removed.)
