On Feb 5, 4:37 am, Jim Weirich <j... / weirichhouse.org> wrote:
> Minkoo Seo wrote:
> > [...]
> > The secondis that lambda returns as we expect, i.e., it
> > returns value, while Proc.new does not.
>
> 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:
>

I guess the following block (do |item| ... end)

>   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

is block and not a proc.

AFAIK, block is not converted to proc unless the block is captured by
parameter like &blk. Am I wrong?

Sincerely,
Minkoo Seo