Code:

def call_block(&c)
  c.call
end

def yield_block(&c)
  yield
end

def lambda_and_call
  c = lambda { return 1 }
  call_block(&c) + 1
end

def lambda_and_yield
  c = lambda { return 1 }
  yield_block(&c) + 1
end

def proc_new_and_call
  c = Proc.new { return 1 }
  call_block(&c) + 1
end

def proc_new_and_yield
  c = Proc.new { return 1 }
  yield_block(&c) + 1
end

[:lambda_and_call, :lambda_and_yield, :proc_new_and_call,
:proc_new_and_yield].each {|m| puts #{m}: #{send(m)}}

Result:

lambda_and_call: 2
lambda_and_yield: 1
proc_new_and_call: 1
proc_new_and_yield: 1
Why 2?
-- 
Posted via http://www.ruby-forum.com/.