diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-20 01:07:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-20 01:07:40 +0000 |
commit | 9bc67e1efad5ec6c54d34d290057268a89886a4c (patch) | |
tree | 42470ef4bb00ff1fb6ddd7b99d8656ae8d7f9935 /cont.c | |
parent | 6628cd6b372837434d97371dc082dba9495ec0cb (diff) |
cont.c: append to continuations doc [ci skip]
* cont.c (rb_callcc): [DOC] append continuations example accros
methods. [Fix GH-1026]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'cont.c')
-rw-r--r-- | cont.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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: * |