[DOC] Harmonize #=~ methods (#15814)

This commit is contained in:
Burdette Lamar 2026-01-07 17:02:22 -06:00 committed by GitHub
parent 5230f835e8
commit 3ea6ec8344
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2026-01-07 23:02:49 +00:00
Merged-By: peterzhu2118 <peter@peterzhu.ca>
2 changed files with 15 additions and 13 deletions

7
re.c
View File

@ -3663,12 +3663,11 @@ reg_match_pos(VALUE re, VALUE *strp, long pos, VALUE* set_match)
/*
* call-seq:
* regexp =~ string -> integer or nil
* self =~ other -> integer or nil
*
* Returns the integer index (in characters) of the first match
* for +self+ and +string+, or +nil+ if none;
* also sets the
* {rdoc-ref:Regexp global variables}[rdoc-ref:Regexp@Global+Variables]:
* for +self+ and +other+, or +nil+ if none;
* updates {Regexp-related global variables}[rdoc-ref:Regexp@Global+Variables].
*
* /at/ =~ 'input data' # => 7
* $~ # => #<MatchData "at">

View File

@ -5011,12 +5011,15 @@ rb_str_byterindex_m(int argc, VALUE *argv, VALUE str)
/*
* call-seq:
* self =~ object -> integer or nil
* self =~ other -> integer or nil
*
* When +object+ is a Regexp, returns the index of the first substring in +self+
* matched by +object+,
* or +nil+ if no match is found;
* updates {Regexp-related global variables}[rdoc-ref:Regexp@Global+Variables]:
* When +other+ is a Regexp:
*
* - Returns the integer index (in characters) of the first match
* for +self+ and +other+, or +nil+ if none;
* - Updates {Regexp-related global variables}[rdoc-ref:Regexp@Global+Variables].
*
* Examples:
*
* 'foo' =~ /f/ # => 0
* $~ # => #<MatchData "f">
@ -5034,8 +5037,8 @@ rb_str_byterindex_m(int argc, VALUE *argv, VALUE str)
* /(?<number>\d+)/ =~ 'no. 9' # => 4
* number # => "9" # Assigned.
*
* If +object+ is not a Regexp, returns the value
* returned by <tt>object =~ self</tt>.
* When +other+ is not a Regexp, returns the value
* returned by <tt>other =~ self</tt>.
*
* Related: see {Querying}[rdoc-ref:String@Querying].
*/
@ -12445,9 +12448,9 @@ sym_casecmp_p(VALUE sym, VALUE other)
/*
* call-seq:
* symbol =~ object -> integer or nil
* self =~ other -> integer or nil
*
* Equivalent to <tt>symbol.to_s =~ object</tt>,
* Equivalent to <tt>self.to_s =~ other</tt>,
* including possible updates to global variables;
* see String#=~.
*