From: "wbsurfver@..." Date: 2007-12-05T04:20:00+09:00 Subject: I think this is cool, ruby iterators and continuations =begin This might be old hat to some, but I just figured out how to make an iterator so that if I get some kind of failure, it will return the element and try again on the same iteration. The code below is just a simulation, but now that I have this example working, I know how to code what I really want. This feature of ruby really impresses me alot ! =end ##################################### $fail = true $cont = nil def proc_tab statement = ["first statement", "second statement", "third statement"] statement.each_with_index do |stat,idx| if $cont cont = $cont $cont = nil cont.call end # simulate a failure on index 1 callcc {|cont| $cont = cont } if idx == 1 and $fail $fail = false if $cont yield stat end end ["searchCIO","searchCRM"].each do |site| (1..5).each do |art| $fail = true puts site + "->" + art.to_s proc_tab do |stat| puts "stat:" + stat end end end