1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Use more different arguments in Fiber.yield documentation to make it clear (#2170)

https://github.com/ruby/ruby/pull/2170#issuecomment-489880700

Documentation is for those who don't know, remember, or understand (to any degree) the language, it should attempt to be clear above all other things. The example given is needlessly unclear because if you use a block it's common for arguments to be reused on every entry to the block. In Fiber's case this is not so.

First time round 10 goes in, 12 comes out.
Second time round 14 goes in, 14 comes out… was that because 14 is 12 + 2 or because it's "the return value of the call to Fiber.yield". It's the latter because it says so but why does the example need to make anyone think the former?

Using different numbers makes it immediately clear what's happening whether the description is there or not.
This commit is contained in:
Iain Barnett 2019-08-17 14:24:45 +09:00 committed by Takashi Kokubun
parent 28267cea08
commit dce1e14e80

6
cont.c
View file

@ -1678,13 +1678,13 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
* end
*
* puts fiber.resume 10
* puts fiber.resume 14
* puts fiber.resume 18
* puts fiber.resume 1_000_000
* puts fiber.resume "The fiber will be dead before I can cause trouble"
*
* <em>produces</em>
*
* 12
* 14
* 1000000
* FiberError: dead fiber called
*
*/