diff --git a/string.c b/string.c index 0f5b5ca955..0d985904b0 100644 --- a/string.c +++ b/string.c @@ -4551,22 +4551,29 @@ rb_str_cmp(VALUE str1, VALUE str2) /* * call-seq: - * string == object -> true or false - * string === object -> true or false + * self == object -> true or false * - * Returns +true+ if +object+ has the same length and content; - * as +self+; +false+ otherwise: + * Returns whether +object+ is equal to +self+. + * + * When +object+ is a string, returns whether +object+ has the same length and content as +self+: * * s = 'foo' - * s == 'foo' # => true + * s == 'foo' # => true * s == 'food' # => false - * s == 'FOO' # => false + * s == 'FOO' # => false * * Returns +false+ if the two strings' encodings are not compatible: + * * "\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 - * two strings are compared using object.==. + * When +object+ is not a string: + * + * - If +object+ responds to method to_str, + * object == self is called and its return value is returned. + * - If +object+ does not respond to to_str, + * +false+ is returned. + * + * Related: {Comparing}[rdoc-ref:String@Comparing]. */ VALUE