Skip to content

Instantly share code, notes, and snippets.

@skwp
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skwp/ef9e06c28899f6006e68 to your computer and use it in GitHub Desktop.
Save skwp/ef9e06c28899f6006e68 to your computer and use it in GitHub Desktop.
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