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:
parent
28267cea08
commit
dce1e14e80
1 changed files with 3 additions and 3 deletions
6
cont.c
6
cont.c
|
@ -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
|
||||
*
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue