From dce1e14e80c9c6d1e25c8aaf9075c80df610ddc3 Mon Sep 17 00:00:00 2001 From: Iain Barnett Date: Sat, 17 Aug 2019 14:24:45 +0900 Subject: [PATCH] Use more different arguments in Fiber.yield documentation to make it clear (#2170) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- cont.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cont.c b/cont.c index ae99a34531..da1075cfb0 100644 --- a/cont.c +++ b/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" * * produces * * 12 - * 14 + * 1000000 * FiberError: dead fiber called * */