[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:02153] Re: begin/else

From: Clemens Hintze <c.hintze@...>
Date: 2000-03-25 07:52:46 UTC
List: ruby-talk #2153
Dat Nguyen writes:
> 

...

> I guess:
> 
> In the first case, if codeA throws an exception, codeB won't be  executed at 
> all.

Yep!

> 
> In the second case, codeB will be executed anyway no matter if codeA throws 
> an exception or not.

Here you're guess is wrong, unfortunately. What you mean is the
'ensure' clause. The 'else' clause will be execute only if codeA
didn't raise an exception. But codeB would not be protected then. That
is, if codeB would throw an exception it would be propagated like an
unhandled one.

BTW: I think perhaps we shouldn't say: 'throw' an exception! In Ruby
exceptions would be 'raise'd. Ruby has another mechanism to 'throw'
something. Same perhaps for 'catch'ing? The other possiblity is the

   catch :sym do
     :
     throw :sym, result unless ...
     :
   end

But here it is not an exception. So perhaps better 'raise'ing
exceptions and 'throw'ing the rest ?!? :-/

> 
> Dat

\cle

-- 
Clemens Hintze  mailto: c.hintze@gmx.net

In This Thread

Prev Next