Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def missing_arguments(block)
block.call('arg1', 'arg2')
end
a_proc = Proc.new { |a, b, c| "a_proc outputs #{a} & #{b} & #{c}" }
a_lambda = lambda { |a, b, c| "a_lambda output #{a} & #{b} & #{c}" }
puts missing_arguments(a_proc)
puts missing_arguments(a_lambda)
@jenny-codes
Copy link
Author

jenny-codes commented Apr 1, 2019

result

a_proc outputs arg1 & arg2 &
Traceback (most recent call last):
	2: from block.rb:40:in `<main>'
	1: from block.rb:33:in `missing_arguments'
proc_lambda_argument.rb:37:in `block in <main>': wrong number of arguments (given 2, expected 3) (ArgumentError)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment