Skip to content

Instantly share code, notes, and snippets.

@jenny-codes
Last active April 1, 2019 11:09
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/92c848dcc27cd3af334466a38bac66e7 to your computer and use it in GitHub Desktop.
Save jenny-codes/92c848dcc27cd3af334466a38bac66e7 to your computer and use it in GitHub Desktop.
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

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