Skip to content

Instantly share code, notes, and snippets.

@axgle
Created February 10, 2010 08:16
Show Gist options
  • Save axgle/300125 to your computer and use it in GitHub Desktop.
Save axgle/300125 to your computer and use it in GitHub Desktop.
def open()
conts={}
callcc do |o| #o是open主节点
callcc{|o1|#o1是子节点1
conts[:o1]=o1
puts "start 1"
o.call #跳到主节点后,子节点2不访问
}#这里是o1节点后
callcc{|o2|#o2是子节点2
puts "start 2"
conts[:close].call#跳到close主节点后
}
end#这里是open主节点后
conts
end
def close(conts)
callcc do |c|
conts[:close]=c
conts[:o1].call #跳到open的o1节点后,然后访问o2节点
end#这里是close主节点后
puts "close"
end
conts=open
close(conts)
http://chinaonrails.com/topic/view/308.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment