Skip to content

Instantly share code, notes, and snippets.

@Sihui
Last active April 27, 2017 05:49
Show Gist options
  • Save Sihui/fb95997104ee0f1a704747afabb64b49 to your computer and use it in GitHub Desktop.
Save Sihui/fb95997104ee0f1a704747afabb64b49 to your computer and use it in GitHub Desktop.
For [Code Block, Proc, Lambda, and Closure in Ruby]()
#Proc
#1. Proc.new followed by a code block
Proc.new { puts 'Hi' }
Proc.new do
puts 'Hi'
end
#2. proc followed by a code block
proc { puts 'Hi' }
proc do
puts 'Hi'
end
#arguments are
# wrapped between ||
times_2 = proc { |num| num * 2 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment