Skip to content

Instantly share code, notes, and snippets.

@atruskie
Created September 8, 2016 05:28
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 atruskie/b82b142177af119c1db6fdba9d790a2c to your computer and use it in GitHub Desktop.
Save atruskie/b82b142177af119c1db6fdba9d790a2c to your computer and use it in GitHub Desktop.
ruby exceptions
# This is a thought exercise.
# Write down the output for the following two invocations
# - `> me false`
# - `> me true`
def me(ensure_fail = false)
begin
puts "inside"
fail "inside error"
rescue => error
puts "rescue"
puts error
puts "re raising"
raise error
ensure
puts "ensure"
fail "ensure error" if ensure_fail
end
puts "end"
end
@atruskie
Copy link
Author

atruskie commented Sep 8, 2016

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