[DOC] Tweaks for String#== (#13323)
This commit is contained in:
parent
76ec41bf3d
commit
10e8119cff
Notes:
git
2025-05-14 19:24:33 +00:00
Merged-By: peterzhu2118 <peter@peterzhu.ca>
23
string.c
23
string.c
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user