Skip to content

Instantly share code, notes, and snippets.

@datayja
Created November 5, 2012 12:59
Show Gist options
  • Save datayja/4017079 to your computer and use it in GitHub Desktop.
Save datayja/4017079 to your computer and use it in GitHub Desktop.
Fun with call/cc in Ruby
require "continuation"
$a = 1
def test
$a = callcc do |cc|
$b = cc
puts $a
3
end
end
test
# 1
# => 3
$a
# => 3
$b.call 2
# => 2
$a
# => 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment