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?
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.
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.
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
> 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.Well, if you think that proc and lambda behave the same, you'll have a
surprise one daymoulon% ./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%
which means , if I remember correctly:
1.8 Proc.new != proc, proc == lambda
1.9 Proc.new == proc, proc!=lambda
right?
Robert
Guy Decoux
···
On 9/22/06, ts <decoux@moulon.inra.fr> wrote:
--
Deux choses sont infinies : l'univers et la bêtise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.
- Albert Einstein
1.8 Proc.new != proc, proc == lambda
1.9 Proc.new == proc, proc!=lambda
yes,
Guy Decoux
> 1.8 Proc.new != proc, proc == lambda
> 1.9 Proc.new == proc, proc!=lambdayes,
Guy Decoux
Thx Guy
···
On 9/22/06, ts <decoux@moulon.inra.fr> wrote:
--
Deux choses sont infinies : l'univers et la bêtise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.
- Albert Einstein