From: angus Date: 2006-02-05T10:34:37+09:00 Subject: Re: continuation [Sch�le Daniel , 2006-02-05 01.58 CET] > Hello, > > irb(main):005:0* cnt=0 > => 0 > irb(main):006:0> cc=nil > => nil > irb(main):007:0> callcc {|cc|} > => nil > irb(main):008:0> cnt+=1 > => 1 > irb(main):009:0> cc.call if cnt < 10 > => nil > irb(main):010:0> cnt > => 1 > irb(main):011:0> > irb(main):012:0* RUBY_VERSION > => "1.8.4" > irb(main):013:0> > > this example is from > http://www.rubygarden.org/ruby?Continuations > and cnt should become 10 The problem is IRB. It is a ruby program whose main loop reads your input, evaluates it, and shows you the result, so when you call the continuation, it only returns to the point where it shows you the result of your input; it doesn't evaluate the statementes you entered later. Try the example outside IRB. --