Skip to content

Commit

Permalink
cont.c: append to continuations doc [ci skip]
Browse files Browse the repository at this point in the history
* cont.c (rb_callcc): [DOC] append continuations example accros
  methods.  [Fix rubyGH-1026]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Sep 20, 2015
1 parent c65e90a commit 8a80fbf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Sun Sep 20 10:07:35 2015 Anton Davydov <antondavydov.o@gmail.com>

* cont.c (rb_callcc): [DOC] append continuations example accros
methods. [Fix GH-1026]

Sun Sep 20 03:20:21 2015 Koichi Sasada <ko1@atdot.net>

* iseq.c (rb_iseq_free): free rb_iseq_t::body::cc_entries.
Expand Down
18 changes: 18 additions & 0 deletions cont.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down

0 comments on commit 8a80fbf

Please sign in to comment.