Created
March 26, 2013 08:37
-
-
Save yyyyyyuanfei/5243928 to your computer and use it in GitHub Desktop.
Experiment on exception and `retry` of Ruby: what scope does the `retry` call effect?
Answer is the method that invokes `retry_me`.
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
| def retry_me(&block) | |
| begin | |
| yield | |
| rescue | |
| retry | |
| end | |
| end | |
| def say_hi | |
| retry_me do | |
| puts "hi" | |
| raise "runrunrun!!" | |
| end | |
| end | |
| say_hi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment