Skip to content

Instantly share code, notes, and snippets.

@tysonmote
Created January 18, 2013 19:33
Show Gist options
  • Select an option

  • Save tysonmote/4567655 to your computer and use it in GitHub Desktop.

Select an option

Save tysonmote/4567655 to your computer and use it in GitHub Desktop.
How to suppress all exceptions without a `rescue` clause.
def bad
raise 'oops'
end
def try
result = yield
ensure
return result
end
try { bad }
# nil
###
def bad
raise 'oops'
end
def try
result = yield
ensure
result
end
try { bad }
# 'oops' exception raised
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment