Skip to content

Instantly share code, notes, and snippets.

@okaram
Created May 28, 2013 15:35
Show Gist options
  • Save okaram/5663643 to your computer and use it in GitHub Desktop.
Save okaram/5663643 to your computer and use it in GitHub Desktop.
Retrying things in ruby
retry_times(5,lambda{ || return 1/0;})
def retry_times(n, func)
n=n-1
return func.call()
rescue => e
puts "n=#{n} exception #{e}"
if n>0 then
retry
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment