[ruby-talk:02545] Re: 'in' vs. 'into'

From: matz@... (Yukihiro Matsumoto)
Date: 2000-04-21 06:26:14 UTC
List: ruby-talk #2545
Hi,

In message "[ruby-talk:02534] Re: 'in' vs. 'into'"
    on 00/04/20, schneik@us.ibm.com <schneik@us.ibm.com> writes:

|#   * exception
|#
|#     This option introcudes new global function `exception' which
|#     returns the $! value.  No reserved word introduced.  I think this
|#     simple way.
|
|What happens if you have recoverable exceptions in exception handlers
|spread across multiple modules written by different people? Would you
|be able to rely on "$!"? (Would the very first thing that you would
|need to do is make a local copy of "$!"?)

Altough undocumented, rescue clause restores previous $! value after
handling exceptions, so that you don't need local copy.

  # $! value is some exception, say an instance of SomeError.
  begin
    codeA
  rescue AnotherError
    # $! is an instance of AnotherError.
    ...
  end
  # old value SomeError restored.

							matz.

In This Thread

Prev Next