Last active
April 27, 2017 06:05
-
-
Save Sihui/c8739a185403b0f1066d8ea23406f332 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
# Returning a proc from a method | |
def fancy_proc_maker | |
proc { puts 'Call me fancy' } | |
end | |
fancy_proc = fancy_proc_maker | |
fancy_proc.call | |
# The above code will print: | |
# Called me fancy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment