Last active
April 27, 2017 03:48
-
-
Save Sihui/b49cf62e37e1d5018abea78feadbf1c1 to your computer and use it in GitHub Desktop.
For [Code Block, Proc, Lambda, and Closure in Ruby]()
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 burger | |
puts 'top bun' | |
yield if block_given? | |
puts 'bottom bun' | |
end | |
burger do | |
puts 'lettuce' | |
puts 'tomato' | |
puts 'chicken breast' | |
end | |
# the above code will prints out | |
# top bun | |
# lettuce | |
# tomato | |
# chicken breast | |
# bottom bun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment