Created
February 4, 2019 18:47
-
-
Save nilbus/06a54e1c6b9f35f3ed03f95907f77ec4 to your computer and use it in GitHub Desktop.
A class with a new constant name can be rescued by either name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[3] pry(main)> class E1 < RuntimeError | |
[3] pry(main)* end | |
=> nil | |
[4] pry(main)> E2 = E1 | |
=> E1 | |
[5] pry(main)> E2 | |
=> E1 | |
[6] pry(main)> def r1 | |
[6] pry(main)* raise E2 | |
[6] pry(main)* rescue E1 | |
[6] pry(main)* :rescued | |
[6] pry(main)* end | |
=> :r1 | |
[7] pry(main)> def r2 | |
[7] pry(main)* raise E1 | |
[7] pry(main)* rescue E2 | |
[7] pry(main)* :rescued | |
[7] pry(main)* end | |
=> :r2 | |
[8] pry(main)> r1 | |
=> :rescued | |
[9] pry(main)> r2 | |
=> :rescued |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment