--0-999368865-1165859141778
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

yeha, yeah, yeah. my mistake.

am new to ruby but now remember that the else is only run if no exceptions occur in the main body. bit of revision there ;)

dblack / wobblini.net wrote: Hi --

On Mon, 11 Dec 2006, Anthony Gardner wrote:

> 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?!

No; I think what you need is just a blank 'rescue', not else:

   begin
     puts "do something"
     raise ZeroDivisionError
   rescue NameError
     puts "name error  #{$!}"
   rescue
     puts "else  #{$!}"
   end

Output:

   do something
   else  ZeroDivisionError

An else clause will run if there's no exception at all.

I don't have my Ruby Way on me but if it says else I think it should
say rescue.


David

-- 
Q. What's a good holiday present for the serious Rails developer?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
    aka The Ruby book for Rails developers!
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)



 		
---------------------------------
 The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider.
--0-999368865-1165859141778--