Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: continuation
Carlos
2/5/2006 1:35:00 AM
[Schüle Daniel <uval@rz.uni-karlsruhe.de>, 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?Con...
> 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.
--
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: continuation
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password