I'm having issue in calling ruby lambda as below.
I'm having a function which accepts a Proc. And lambda definition as below.
def call_proc_with_arg(&b)
b.call(1)
end
lam = -> (a) { puts "printing the argument #{a}"}
And when I try to pass the lambda to function as,
call_proc_with_arg(lam)
I'm getting the error,
Traceback (most recent call last): 6: from /usr/bin/irb:23:in
<main>' 5: from /usr/bin/irb:23:inload' 4: from /Library/Ruby/Gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in<top (required)>' 3: from (irb):118 2: from (irb):118:inrescue in irb_binding' 1: from (irb):52:in `call_block' ArgumentError (wrong number of arguments (given 1, expected 0))
Whereas the function works with block,
call_proc_with_arg {|a| puts "printing the argument #{a}"}
What am I missing with lambda?