Skip to content

Instantly share code, notes, and snippets.

@Sihui
Last active April 27, 2017 06:05
Show Gist options
  • Save Sihui/c8739a185403b0f1066d8ea23406f332 to your computer and use it in GitHub Desktop.
Save Sihui/c8739a185403b0f1066d8ea23406f332 to your computer and use it in GitHub Desktop.
For [Code Block, Proc, Lambda, and Closure in Ruby]()
# 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