4 ms·
Also, they behave slightly different when it comes to arity: def nuts(a, b) end foo = Proc.new { |a, b| } nuts(1, 2, 3) # => ArgumentError: w
by judofyr 17y ago
Also, they behave slightly different when it comes to arity:
def nuts(a, b)
end
foo = Proc.new { |a, b| }
nuts(1, 2, 3) # => ArgumentError: wrong number of arguments (3 for 2)
foo.call(1, 2, 3) # works fine
We also have lambda, which is a Proc that works (almost) as a method: http://samdanielson.com/2007/3/19/proc-new-vs-lambda-in-ruby http://samdanielson.com/2007/3/19/proc-new-vs-lambda-in-ruby