From: Robert Klemme Date: 2006-12-12T19:10:08+09:00 Subject: Re: Bug in Ruby or Pickaxe? On 12.12.2006 00:15, Dave Thomas wrote: > > On Dec 11, 2006, at 7:55 AM, Robert Klemme wrote: > >> What bugs me is that the "else" clause is not executed if it is left >> via a "return". Taking the Pickaxe 2nd edition pg. 362 literally ("If >> an else clause is present, its body is executed if no exceptions were >> raised in code.") it would have to be executed in that case, too. So, >> if the interpreter would behave as stated in the book, there was >> actually a difference between the code at the end of the block and the >> code inside the else clause. > > Why would you expect the else clause to be executed if a return is > executed? That seems counter-intuitive to me. I have low expectations with regard to the "else" clause but the book clearly states that it is executed if there was no exception - that includes the case where the block is left via a "return". Behavior and description simply are not in sync, that's my point. I can't remember ever having used this type of "else" clause so far so I am pretty nonreligious about it. Although I can imagine a situation where I would want to make sure some cleanup code is executed only when there was no error in the block - and this includes leaving via "return". Of course you can argue that leaving via "return" is a non standard way to leave the block... As I said, I am pretty relaxed here. I just think this needs some clarification - either way or the other. Kind regards robert