From: Jim Weirich Date: 2007-02-05T04:37:57+09:00 Subject: Re: Proc vs lambda vs proc Minkoo Seo wrote: > [...] > The secondis that lambda returns as we expect, i.e., it > returns value, while Proc.new does not. > > [...] I guess > there might be some situation where Proc.new is more suitable than > lambda. [...] lambda and Proc.new do handle the return statement in different ways. Return in lambda returns from the lambda, treating the lambda as an anonymous function. Return in Proc.new returns from the enclosing method, treating the block as an inline piece of code. The Proc.new behavior is useful where the block is simply a bit the algorithm. For example: def member?(target, list) list.each do |item| return true if target == item end false end The explicit return should return from the member? method, not just from the loop. -- Jim Weirich -- Posted via http://www.ruby-forum.com/.