Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class · Ruby 4.1

LocalJumpError

< StandardError 2 instance methods

Raised when Ruby can’t yield as requested.

A typical scenario is attempting to yield when no block is given:

Example
def call_block
  yield 42
end
call_block

raises the exception:

LocalJumpError: no block given (yield)

A more subtle example:

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

raises the exception:

LocalJumpError: unexpected return

Instance methods 2