[ next ] [ prev ] [ contents ] Invitation To Ruby

Continuations

  1: #!/usr/bin/env ruby
  2: 
  3: puts "First Example"
  4: value = callcc { |continuation|
  5:   continuation.call
  6:   puts "Never Called"
  7: }
  8: puts "Continuing"
  9: 
 10: puts
 11: puts "Second Example"
 12: p = callcc { |continuation| continuation }
 13: puts "Again ..."
 14: p.call(proc { puts "The End" })

Output

First Example
Continuing

Second Example
Again ...
Again ...
The End



[ next ] [ prev ] [ contents ] Copyright 2002 by Jim Weirich.
All rights reserved.