Created
January 25, 2009 00:59
-
-
Save jptix/51618 to your computer and use it in GitHub Desktop.
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
def foo(&block) | |
puts :a | |
yield | |
puts :c | |
end | |
foo { puts :b } | |
# >> a | |
# >> b | |
# >> c | |
foo { puts :b; break } | |
# >> a | |
# >> b | |
foo { puts :b; next } | |
# >> a | |
# >> b | |
# >> c | |
foo { puts :b; return } | |
# ~> unexpected return (LocalJumpError) | |
def bar(block) | |
puts :a | |
block.call | |
puts :c | |
end | |
bar(lambda { puts :b; return }) | |
# >> a | |
# >> b | |
# >> c | |
bar(lambda { puts :b; next }) | |
# >> a | |
# >> b | |
# >> c | |
bar(lambda { puts :b; break }) | |
# >> a | |
# >> b | |
# >> c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment