Created
September 8, 2016 05:28
-
-
Save atruskie/b82b142177af119c1db6fdba9d790a2c to your computer and use it in GitHub Desktop.
ruby exceptions
This file contains 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
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Answers: https://gist.github.com/atruskie/e695d35dda5b38cc7912ea9bfe84e7df