Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Created August 23, 2017 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dongyuwei/5d30cb85fa74ca3c4c339bbb5adf41ba to your computer and use it in GitHub Desktop.
Save dongyuwei/5d30cb85fa74ca3c4c339bbb5adf41ba to your computer and use it in GitHub Desktop.
test recursive function call in rescue block
@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}"
@dongyuwei
Copy link
Author

expected output is 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment