Skip to content

Instantly share code, notes, and snippets.

@Fitzsimmons
Created June 4, 2012 17:16
Show Gist options
  • Save Fitzsimmons/2869632 to your computer and use it in GitHub Desktop.
Save Fitzsimmons/2869632 to your computer and use it in GitHub Desktop.
Local Jump Errors
class T
def initialize(&block)
self.class.send(:define_method, :runner, &block)
end
def do_stuff
self.runner do |thing|
puts thing
end
end
end
t = T.new do
yield "hello, "
yield "world"
end
begin
t.do_stuff
rescue LocalJumpError
puts "LocalJumpError caught"
end
#########################################
class P
def initialize(runner)
@runner = runner
end
def do_stuff
@runner.call do |thing|
puts thing
end
end
end
l = lambda do
yield "proc, "
yield "hello"
end
p = P.new(l)
p.do_stuff #Also LocalJumpError, wtf!?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment