Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# set up instances
# Since blocks cannot be stored in a variable, we create a method to inspect it.
def dummy_method(&a_block)
puts "A block is a #{a_block.class}"
puts "A block instance: #{a_block.inspect}"
end
a_proc = Proc.new { 'This is a proc' }
a_lambda = lambda { 'This is a lamnda' }
# test begins
dummy_method { 'This is a block' }
puts "A proc is a #{a_proc.class}"
puts "A proc instance: #{a_proc.inspect}"
puts "A lambda is a #{a_lambda.class}"
puts "A lambda instance: #{a_lambda.inspect}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment