Ruby 2.4

LocalJumpError

LocalJumpError类

Parent:StandardError

当Ruby无法按要求屈服时引发。

一个典型的场景是在没有给出块的情况下尝试屈服:

def call_block yield 42 end call_block

引发了一个例外:

LocalJumpError: no block given (yield)

一个更微妙的例子:

def get_me_a_return Proc.new { return 42 } end get_me_a_return.call

引发了一个例外:

LocalJumpError: unexpected return

公共实例方法

exit_value → obj Show source

返回与此关联的退出值LocalJumpError

static VALUE localjump_xvalue(VALUE exc) { return rb_iv_get(exc, "@exit_value" }

reason → symbol Show source

这个块被终止的原因::break,:redo,:retry,:next,:return或者noreason。

static VALUE localjump_reason(VALUE exc) { return rb_iv_get(exc, "@reason" }