Created
April 23, 2017 17:45
-
-
Save Sihui/812a47cad138874b83f6bd3a700a9d3c 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
# Example: passing arguments | |
def ten_plus | |
puts 'before yield' | |
yield(10) | |
puts 'after yield' | |
end | |
ten_plus do |num| | |
puts(num + 100) | |
end | |
# the above code will prints out | |
# before yield | |
# 110 | |
# after yield | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment