Created
August 23, 2017 03:37
-
-
Save dongyuwei/5d30cb85fa74ca3c4c339bbb5adf41ba to your computer and use it in GitHub Desktop.
test recursive function call in rescue block
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
@max_count = 5 | |
def recursive_test(p1) | |
begin | |
if @max_count > 1 | |
raise "test" | |
else | |
@max_count + p1 | |
end | |
rescue | |
@max_count = @max_count - 1 | |
if @max_count > 0 | |
puts "@max_count: #{@max_count}, #{p1}" | |
recursive_test(p1) | |
end | |
end | |
end | |
data = recursive_test(10) | |
puts "===== data:#{data}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
expected output is 11