Skip to content

Instantly share code, notes, and snippets.

@rummelonp
Last active December 14, 2015 22:48
Show Gist options
  • Save rummelonp/5160570 to your computer and use it in GitHub Desktop.
Save rummelonp/5160570 to your computer and use it in GitHub Desktop.
!!! goto !!!
require 'continuation'
module Kernel
def labels
$labels ||= {}
end
def label(name)
callcc { |c| labels[name] = c }
end
def goto(name)
labels[name].call
end
end
i = 0
label 10
puts i += 1
goto 10 if i < 10
label :nyan
puts i -= 1
goto :nyan if i > 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment