Skip to content

Instantly share code, notes, and snippets.

@pastafari
Created July 15, 2011 13:40
Show Gist options
  • Save pastafari/1084706 to your computer and use it in GitHub Desktop.
Save pastafari/1084706 to your computer and use it in GitHub Desktop.
Got Sandwich Code? Use blocks...
def method_that_takes_implicit_block
#do bread part of code here
yield
#remaining bread part
end
def method_that_takes_explicit_block(&block)
#do bread part of code here
block.call
#remaining bread part
end
method_that_takes_implicit_block do
puts "This is the meat of the matter"
end
method_that_takes_explicit_block do
puts "This is the meat of the matter"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment