Taken from the documentation for Proc#lambda?:
Returns true for a Proc object for which argument handling is rigid. Such procs are typically generated by lambda.
What is "rigid argument" handling?
Lambdas will raise an ArgumentError if passed the wrong number of arguments, Proc.new won't.
Example:
lam = ->(x){ "OK" }
lam.lambda? # => true
lam.call # => ArgumentError
lam.call(1) # => OK
proc = Proc.new { |x| "OK" }
proc.lambda? # => false
proc.call # => OK
proc.call(1) # => OK
proc.call(1,2,3,4,5,6,7,8,9) # => OK
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With