Last active
December 24, 2015 02:49
-
-
Save flash-gordon/6732815 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def yield_and_ensure | |
yield | |
ensure | |
'ensure' | |
end | |
def yield_and_return_ensure | |
yield | |
ensure | |
return 'ensure' | |
end | |
def without_return | |
result = yield_and_ensure {return 'block'} | |
p 'without_return is still running' | |
result | |
end | |
def with_return | |
result = yield_and_return_ensure {return 'block'} | |
p 'with_return is still running' | |
result | |
end | |
p without_return | |
p with_return | |
# stdout: | |
# "block" | |
# "with_return is still running" | |
# "ensure" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment