Kyung won Cheon wrote:
> def a
>   blk = Proc.new { return }
>   blk.call
> end
> 
> a                         # => It's OK
> 
> def a(blk)
>   blk.call
> end
> 
> blk = lambda { return }
> a blk                     # => It's OK
> 
> blk = Proc.new { return }
> a blk                     # => unexpected return (LocalJumpError) 

% ruby -e 'return'
-e:1: unexpected return (LocalJumpError)

That is what you are seeing.  'return' interrupts a method, but there is 
no method at the top-level scope.

def a(blk)
  blk.call
end

def main
  blk = Proc.new { return }
  p "before"
  a blk
  p "after"  # never gets here
end

main  # => "before"
-- 
Posted via http://www.ruby-forum.com/.