ruby-changes:61692
From: Jeremy <ko1@a...>
Date: Sat, 13 Jun 2020 01:13:48 +0900 (JST)
Subject: [ruby-changes:61692] b212c7c7d1 (master): Update example code in Enumerator#chunk documentation [ci skip]
https://git.ruby-lang.org/ruby.git/commit/?id=b212c7c7d1 From b212c7c7d136dad7391874c5c9ba0b77df5653e2 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Fri, 12 Jun 2020 09:11:43 -0700 Subject: Update example code in Enumerator#chunk documentation [ci skip] The code assumed that /usr/share/dict/words did not use mixed case, and it does at least on a few operating systems. From CryptoRAT (Luke Elliot) Fixes [Bug #16957] diff --git a/enum.c b/enum.c index f49b684..8c8adcf 100644 --- a/enum.c +++ b/enum.c @@ -3203,7 +3203,7 @@ chunk_i(RB_BLOCK_CALL_FUNC_ARGLIST(yielder, enumerator)) https://github.com/ruby/ruby/blob/trunk/enum.c#L3203 * The following example counts words for each initial letter. * * open("/usr/share/dict/words", "r:iso-8859-1") { |f| - * f.chunk { |line| line.ord }.each { |ch, lines| p [ch.chr, lines.length] } + * f.chunk { |line| line.upcase.ord }.each { |ch, lines| p [ch.chr, lines.length] } * } * #=> ["\n", 1] * # ["A", 1327] -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/