proc and lambda

S

Sourav

What is the difference between proc function and lambda function when
they both create new Proc object? Is there any guidelines for
preferring one over another?
 
S

Sourav

Provided of course, I know the differences between Proc.new and lambda
~ both proc and lambda seems to behave the way, whereas, Proc.new
behaves slightly differently.
 
T

ts

S> Provided of course, I know the differences between Proc.new and lambda
S> ~ both proc and lambda seems to behave the way, whereas, Proc.new
S> behaves slightly differently.

Well, if you think that proc and lambda behave the same, you'll have a
surprise one day :)

moulon% ./ruby -ve 'proc { break }.call'
ruby 1.9.0 (2006-09-21) [i686-linux]
-e:1: break from proc-closure (LocalJumpError)
from -e:1:in `Proc#call'
from -e:1
moulon%

moulon% ./ruby -ve 'lambda { break }.call'
ruby 1.9.0 (2006-09-21) [i686-linux]
moulon%



Guy Decoux
 
T

ts

R> 1.8 Proc.new != proc, proc == lambda
R> 1.9 Proc.new == proc, proc!=lambda

yes,


Guy Decoux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top