M
Mark Volkmann
I understand that the code in the else part of a begin block is only
executed if no exceptions are raised by code in the begin block.
However, the same is true of code at the end of the begin block. Why
not put the code there?
For example, I believe these are equivalent.
begin
do_something
rescue
handle_exception
else
do_more_stuff
end
begin
do_something
do_more_stuff
rescue
handle_exception
end
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?
executed if no exceptions are raised by code in the begin block.
However, the same is true of code at the end of the begin block. Why
not put the code there?
For example, I believe these are equivalent.
begin
do_something
rescue
handle_exception
else
do_more_stuff
end
begin
do_something
do_more_stuff
rescue
handle_exception
end
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?