summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
authorBenoit Daloze <[email protected]>2022-12-20 22:10:37 +0100
committerBenoit Daloze <[email protected]>2022-12-20 23:05:56 +0100
commit4495dea153a097c59d56819bc827bebfbef5be3f ()
tree4d3ecaf69b58325d7a058d3d7e369a18b21ae850 /enumerator.c
parent39e70eef724d1c4b50a6ee894c35a3e60773671c (diff)
Improve documentation for fiber-scoped variables
* Especially around Enumerator.
Notes: Merged: https://.com/ruby/ruby/pull/6974
-rw-r--r--enumerator.c45
1 files changed, 38 insertions, 7 deletions
@@ -73,6 +73,8 @@
* puts %w[foo bar baz].map.with_index { |w, i| "#{i}:#{w}" }
* # => ["0:foo", "1:bar", "2:baz"]
*
* An Enumerator can also be used as an external iterator.
* For example, Enumerator#next returns the next value of the iterator
* or raises StopIteration if the Enumerator is at the end.
@@ -83,15 +85,44 @@
* puts e.next # => 3
* puts e.next # raises StopIteration
*
- * Note that enumeration sequence by +next+, +next_values+, +peek+ and
- * +peek_values+ do not affect other non-external
- * enumeration methods, unless the underlying iteration method itself has
- * side-effect, e.g. IO#each_line.
*
- * Moreover, implementation typically uses fibers so performance could be
- * slower and exception stacktraces different than expected.
*
- * You can use this to implement an internal iterator as follows:
*
* def ext_each(e)
* while true