From: Anthony Gardner Date: 2006-12-11T21:54:39+09:00 Subject: Re: else inside rescue is useless? --0-493470381-1165841660=:52701 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit exactly, the else is in the rescue which means an exception has been thrown. if it doesn;t match any of the exceptions you've declared as being important to catching, and you include an else, the else wiill catch what you don;t want. no?! cap wrote: http://www.awprofessional.com/bookstore/product.asp?isbn=0672328844&rl=1 The "The ruby way" book said [quote] In the event that error types are specified, it may be that an exception does not match any of these types. For that situation, we are allowed to use an else clause after all the rescue clauses. begin # Error-prone code... rescue Type1 # ... rescue Type2 # ... else # Other exceptions... end [/quote] but actually, I found the "else" clause is only executed when there is no exception been thrown,such as : ------------------------- begin puts "do something" rescue NameError puts "name error #{$!}" else puts "else #{$!}" end -------------------------- the result is ------------------- do something else ------------------ so the "else" clause is useless because we can simply put the content of "else" caluse to the last line in the "begin" block before the first "rescue" Am I wrong or the book is wrong? my ruby version is ruby 1.8.4 (2005-12-24) [i686-linux] --------------------------------- The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. --0-493470381-1165841660=:52701--