Last active
August 29, 2015 14:15
-
-
Save skwp/ef9e06c28899f6006e68 to your computer and use it in GitHub Desktop.
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
class BlocksAreProcs | |
def try_to_invoke_block | |
foo do | |
puts "start here" | |
return | |
end | |
end | |
def foo | |
yield | |
puts "i will never get here" | |
end | |
end | |
class ProcsAreProcs | |
def try_to_invoke_block | |
myproc = Proc.new do | |
puts "start here" | |
return | |
end | |
foo(&myproc) | |
end | |
def foo(&block) | |
block.call | |
puts "i will never get here" | |
end | |
end | |
class Lambdas | |
def try_to_invoke_block | |
mylambda = lambda do | |
puts "start here" | |
return | |
end | |
foo(&mylambda) | |
end | |
def foo(&block) | |
block.call | |
puts "i will get here, just fine, thanks!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment