Skip to content

Commit

Permalink
string.c: Follow up to ae2359f
Browse files Browse the repository at this point in the history
* Mention `\0`
* Make the example of hash replacement meaningful
  • Loading branch information
mame committed Nov 2, 2021
1 parent a4f834c commit 4b248e7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions string.c
Expand Up @@ -11859,7 +11859,7 @@ rb_enc_interned_str_cstr(const char *ptr, rb_encoding *enc)
* 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.
Expand Down Expand Up @@ -11894,11 +11894,12 @@ rb_enc_interned_str_cstr(const char *ptr, rb_encoding *enc)
* 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>
*
Expand Down

0 comments on commit 4b248e7

Please sign in to comment.