diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | cont.c | 18 |
2 files changed, 23 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Sun Sep 20 10:07:35 2015 Anton Davydov <[email protected]> + + * cont.c (rb_callcc): [DOC] append continuations example accros + methods. [Fix GH-1026] + Sun Sep 20 03:20:21 2015 Koichi Sasada <[email protected]> * iseq.c (rb_iseq_free): free rb_iseq_t::body::cc_entries. @@ -893,6 +893,24 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame) * Ron * Max * + * Also you can call callcc in other methods: + * + * require "continuation" + * + * def g + * arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ] + * cc = callcc { |cc| cc } + * puts arr.shift + * return cc, arr.size + * end + * + * def f + * c, size = g + * c.call(c) if size > 1 + * end + * + * f + * * This (somewhat contrived) example allows the inner loop to abandon * processing early: * |