Created
February 19, 2014 16:25
-
-
Save rewinfrey/9095583 to your computer and use it in GitHub Desktop.
procs vs. lambdas
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
def some_method | |
some_method2 | |
puts "here" | |
end | |
def another_method | |
puts "in another method" | |
return | |
end | |
def some_method2 | |
puts "in some method 2" | |
another_method | |
name = "dude" | |
->{ | |
puts "in lambda in some method 2" | |
puts name | |
return | |
}.call | |
Proc.new { |input1, input2| | |
puts "in proc in some method 2" | |
puts input1 | |
puts input2 | |
puts name | |
return | |
}.call | |
puts "after proc in some method 2" | |
end | |
some_method | |
# >> in some method 2 | |
# >> in lambda in some method 2 | |
# >> dude | |
# >> in proc in some method 2 | |
# >> | |
# >> | |
# >> dude | |
# >> here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment