[DOC] Tweaks for String#== (#13323)

This commit is contained in:
Burdette Lamar 2025-05-14 14:24:19 -05:00 committed by GitHub
parent 76ec41bf3d
commit 10e8119cff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-05-14 19:24:33 +00:00
Merged-By: peterzhu2118 <peter@peterzhu.ca>

View File

@ -4551,22 +4551,29 @@ rb_str_cmp(VALUE str1, VALUE str2)
/* /*
* call-seq: * call-seq:
* string == object -> true or false * self == object -> true or false
* string === object -> true or false
* *
* Returns +true+ if +object+ has the same length and content; * Returns whether +object+ is equal to +self+.
* as +self+; +false+ otherwise: *
* When +object+ is a string, returns whether +object+ has the same length and content as +self+:
* *
* s = 'foo' * s = 'foo'
* s == 'foo' # => true * s == 'foo' # => true
* s == 'food' # => false * s == 'food' # => false
* s == 'FOO' # => false * s == 'FOO' # => false
* *
* Returns +false+ if the two strings' encodings are not compatible: * Returns +false+ if the two strings' encodings are not compatible:
*
* "\u{e4 f6 fc}".encode(Encoding::ISO_8859_1) == ("\u{c4 d6 dc}") # => false * "\u{e4 f6 fc}".encode(Encoding::ISO_8859_1) == ("\u{c4 d6 dc}") # => false
* *
* If +object+ is not an instance of +String+ but responds to +to_str+, then the * When +object+ is not a string:
* two strings are compared using <code>object.==</code>. *
* - If +object+ responds to method <tt>to_str</tt>,
* <tt>object == self</tt> is called and its return value is returned.
* - If +object+ does not respond to <tt>to_str</tt>,
* +false+ is returned.
*
* Related: {Comparing}[rdoc-ref:String@Comparing].
*/ */
VALUE VALUE