【发布时间】:2010-09-23 16:34:17
【问题描述】:
以下代码在 Ruby 中的 Python 等效项是什么?
def loop
cont=nil
for i in 1..4
puts i
callcc {|continuation| cont=continuation} if i==2
end
return cont
end
> c=loop
1
2
3
4
> c.call
3
4
参考:Secrets of lightweight development success, Part 9: Continuations-based frameworks
【问题讨论】:
标签: python ruby continuations