4 ms·
See here: http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/ http://www.robertsosinski.com/2008/12/21/understanding-ruby-...
by carbon8 17y ago
See here: http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/ http://www.robertsosinski.com/2008/12/21/understanding-ruby-...
Proc objects created with lambda check arguments and have "diminutive return" so they behave as anonymous methods.
Also, Kernel#proc is an alias to Kernel#lambda, so the only way you get the bare Proc behavior is by calling Proc.new directly.
- blubb 17y agoAh, I didn't know that Proc.new != proc/lambda :) They both return Proc objects though, so I wonder if it is possible to "convert" them.
- carbon8 17y agoOne small note, as pointed out in http://innig.net/software/ruby/closures-in-ruby.rb http://innig.net/software/ruby/closures-in-ruby.rb posted by arohner above: although in 1.8 proc is an alias for lambda, in 1.9 it's now an alias for Proc.new.