ruby-changes:69570
From: Yusuke <ko1@a...>
Date: Wed, 3 Nov 2021 03:53:48 +0900 (JST)
Subject: [ruby-changes:69570] 4b248e7994 (master): string.c: Follow up to ae2359f602bb467ca755eef02d73d361d35eaed7
https://git.ruby-lang.org/ruby.git/commit/?id=4b248e7994 From 4b248e7994e68fa5075f62d4cbfb36514ffd7bfa Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Wed, 3 Nov 2021 03:52:28 +0900 Subject: string.c: Follow up to ae2359f602bb467ca755eef02d73d361d35eaed7 * Mention `\0` * Make the example of hash replacement meaningful --- string.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/string.c b/string.c index aa26f35d60a..154f8e98d9d 100644 --- a/string.c +++ b/string.c @@ -11859,7 +11859,7 @@ rb_enc_interned_str_cstr(const char *ptr, rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/string.c#L11859 * However, you may refer to some special match variables using these * combinations: * - * - <tt>\&</tt> corresponds to <tt>$&</tt>, + * - <tt>\&</tt> and <tt>\0</tt> correspond to <tt>$&</tt>, * which contains the complete matched text. * - <tt>\'</tt> corresponds to <tt>$'</tt>, * which contains string after match. @@ -11894,11 +11894,12 @@ rb_enc_interned_str_cstr(const char *ptr, rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/string.c#L11894 * the replacing string is the value for that key: * * h = {'foo' => 'bar', 'baz' => 'bat'} - * 'food'.sub('oo', h) # => "fd" + * 'food'.sub('foo', h) # => "bard" + * + * Note that a symbol key does not match: + * * h = {foo: 'bar', baz: 'bat'} - * 'food'.sub('oo', h) # => "fd" - * h = {foo: :bar, baz: :bat} - * 'food'.sub('oo', h) # => "fd" + * 'food'.sub('foo', h) # => "d" * * <b>Block</b> * -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/