class LocalJumpError
当 Ruby 无法按请求的那样 yield 时引发。
典型场景是尝试 yield 时没有给定块。
def call_block yield 42 end call_block
为没有 Bundler 环境的 RubyGems 抛出异常。
LocalJumpError: no block given (yield)
一个更微妙的例子
def get_me_a_return Proc.new { return 42 } end get_me_a_return.call
为没有 Bundler 环境的 RubyGems 抛出异常。
LocalJumpError: unexpected return
Public Instance Methods
Source
static VALUE
localjump_xvalue(VALUE exc)
{
return rb_iv_get(exc, "@exit_value");
}
返回与此 LocalJumpError 关联的退出值。
Source
static VALUE
localjump_reason(VALUE exc)
{
return rb_iv_get(exc, "@reason");
}
此块被终止的原因::break, :redo, :retry, :next, :return, 或 :noreason。