Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. require 'continuation'
  2.  
  3. counter = 0
  4. inner_counter = 0
  5.  
  6. go_to_counter = callcc { |x| x }
  7. counter += 1
  8. puts "I've restarted #{counter} times"
  9.  
  10. go_to_inner_counter = callcc { |x| x }
  11. inner_counter += 1
  12. puts "I've gone to inner counter #{inner_counter} times"
  13.  
  14. if (inner_counter % 2).zero?
  15. go_to_inner_counter.call(go_to_inner_counter)
  16. end
  17.  
  18. go_to_counter.call(go_to_counter) if counter < 10
  19.  
  20. puts "OK I'm done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement