Skip to content

Instantly share code, notes, and snippets.

@jptix
Created January 25, 2009 00:59
Show Gist options
  • Save jptix/51618 to your computer and use it in GitHub Desktop.
Save jptix/51618 to your computer and use it in GitHub Desktop.
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