Created
July 15, 2011 13:40
-
-
Save pastafari/1084706 to your computer and use it in GitHub Desktop.
Got Sandwich Code? Use blocks...
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 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