Skip to content

Instantly share code, notes, and snippets.

@jenny-codes
Last active April 1, 2019 05:44
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 jenny-codes/23fc0f97a9325581d74f12aff8580c44 to your computer and use it in GitHub Desktop.
Save jenny-codes/23fc0f97a9325581d74f12aff8580c44 to your computer and use it in GitHub Desktop.
# 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