Last active
April 27, 2017 05:51
-
-
Save Sihui/64dfbd160b96d3f4f769f19efc0c5647 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
#Lambda | |
# 1. lambda followed by a code block | |
lambda { puts 'Hi' } | |
lambda do | |
puts 'Hi' | |
end | |
#2. -> (stabby lambda) | |
-> { puts 'Hi' } | |
-> do | |
puts 'Hi' | |
end | |
#-> takes argument outside of {} | |
times_2 = -> (num) { num * 2 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment