One not documented behavior im lambda

proc { |…| block } => a_proc, lambda { |…| block } => a_procEquivalent to Proc.new, except the resulting Proc objects check the number of parameters passed when called.
Ruby official doc

But at least are one more difference :

def foo
  f = Proc.new { return "return from foo from inside proc" }

  f.call # control leaves foo here

  return "return from foo"

end

def bar

  f = lambda { return "return from lambda" }

  f.call # control does not leave bar here

  return "return from bar"

end

puts foo # prints "return from foo from inside proc"

puts bar # prints "return from bar"

Wikipedia

Advertisements

2 comments so far

  1. name on

    Good day!,

  2. name on

    Hello!,


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: