From: Ken Bloom Date: 2008-04-19T00:10:06+09:00 Subject: Re: When are lambdas needed? On Fri, 18 Apr 2008 05:43:49 -0500, David A. Black wrote: > Hi -- > > On Fri, 18 Apr 2008, Ken Bloom wrote: > >> The difference between lambda and the other ways of getting a Proc >> object is that lambda treats return, next, and break a little bit >> differently. > > It's actually a difference between lambda and proc (which are synonyms), > on the one hand, and Proc.new on the other: > > irb(main):009:0> lambda { return }.call => nil > irb(main):010:0> proc { return }.call => nil > irb(main):011:0> Proc.new { return }.call LocalJumpError: unexpected > return > > Since it's a bit confusing to have proc and Proc.new be different, this > has been changed in 1.9: proc and Proc.new are the same in 1.9, and > lambda is different. > > (I still have no idea how to memorize which is which.) That's why I tried to be intentionally vague about the differences, but I guess I wasn't vague enough. Thanks everybody for filling in the details. --Ken -- Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/