# Proc and lambda

**URL:** <https://rubytalk.org/t/proc-and-lambda/31228>\
**Category:** ruby-talk\
**Created:** [22 September 2006 12:10 UTC](https://rubytalk.org/t/proc-and-lambda/31228 "2006-09-22T12:10:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sourav](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@Sourav](https://rubytalk.org/u/Sourav)\
**Post date:** [22 September 2006 12:10 UTC](https://rubytalk.org/t/proc-and-lambda/31228/1 "2006-09-22T12:10:15Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Sourav](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@Sourav](https://rubytalk.org/u/Sourav)\
**Post date:** [22 September 2006 12:20 UTC](https://rubytalk.org/t/proc-and-lambda/31228/2 "2006-09-22T12:20:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ts1](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@ts1](https://rubytalk.org/u/ts1)\
**Post date:** [22 September 2006 12:25 UTC](https://rubytalk.org/t/proc-and-lambda/31228/3 "2006-09-22T12:25:28Z")

</div>

> 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)  
&nbsp;&nbsp;from -e:1:in `Proc#call'  
&nbsp;&nbsp;from -e:1  
moulon%

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

Guy Decoux

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [22 September 2006 13:19 UTC](https://rubytalk.org/t/proc-and-lambda/31228/4 "2006-09-22T13:19:21Z")

</div>

> \> 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)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from -e:1:in `Proc#call'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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

---

<div class="post-metadata">

**Author:** ![ts1](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@ts1](https://rubytalk.org/u/ts1)\
**Post date:** [22 September 2006 13:31 UTC](https://rubytalk.org/t/proc-and-lambda/31228/5 "2006-09-22T13:31:12Z")

</div>

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

yes,

Guy Decoux

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [22 September 2006 14:11 UTC](https://rubytalk.org/t/proc-and-lambda/31228/6 "2006-09-22T14:11:10Z")

</div>

> \> 1.8 Proc.new != proc, proc == lambda  
> \> 1.9 Proc.new == proc, proc!=lambda
> 
> yes,
> 
> 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
