U:RDoc::NormalClass[iI"Continuation:ET@I" Object;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[ I":Continuation objects are generated by Kernel#callcc, ;TI"continuation. They hold ;TI"Ha return address and execution context, allowing a nonlocal return ;TI"Hto the end of the callcc block from anywhere within a ;TI"Cprogram. Continuations are somewhat analogous to a structured ;TI"Gversion of C's setjmp/longjmp (although they contain ;TI"?more state, so you might consider them closer to threads).;To:RDoc::Markup::BlankLineo; ;[I"For instance:;T@o:RDoc::Markup::Verbatim;[ I"require "continuation" ;TI":arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ] ;TI"callcc{|cc| $cc = cc} ;TI"puts(message = arr.shift) ;TI"&$cc.call unless message =~ /Max/ ;T: @format0o; ;[I"produces:;T@o; ;[ I" Freddie ;TI" Herbie ;TI" Ron ;TI" Max ;T; 0o; ;[I"/Also you can call callcc in other methods:;T@o; ;[I"require "continuation" ;TI" ;TI" def g ;TI"< arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ] ;TI" cc = callcc { |cc| cc } ;TI" puts arr.shift ;TI" return cc, arr.size ;TI" end ;TI" ;TI" def f ;TI" c, size = g ;TI" c.call(c) if size > 1 ;TI" end ;TI" ;TI"f ;T; 0o; ;[I"HThis (somewhat contrived) example allows the inner loop to abandon ;TI"processing early:;T@o; ;[I"require "continuation" ;TI"callcc {|cont| ;TI" for i in 0..4 ;TI" print "\n#{i}: " ;TI" for j in i*5...(i+1)*5 ;TI"" cont.call() if j == 17 ;TI" printf "%3d", j ;TI" end ;TI" end ;TI"} ;TI" puts ;T; 0o; ;[I"produces:;T@o; ;[ I"0: 0 1 2 3 4 ;TI"1: 5 6 7 8 9 ;TI"2: 10 11 12 13 14 ;TI"3: 15 16;T; 0: @fileI" cont.c;T:0@omit_headings_from_table_of_contents_below0; 0;0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[;[[I"[];TI" cont.c;T[I" call;T@m[;[[;[[[U:RDoc::Context::Section[i0o;;[; 0;0[@X@XcRDoc::TopLevel