Method: String#===

Defined in:
string.c

#==(object) ⇒ Boolean #===(object) ⇒ Boolean

Returns true if object has the same length and content; as self; false otherwise:

s = 'foo'
s == 'foo' # => true
s == 'food' # => false
s == 'FOO' # => false

Returns false if the two strings’ encodings are not compatible:

"\u{e4 f6 fc}".encode("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.==.

Overloads:

  • #==(object) ⇒ Boolean

    Returns:

    • (Boolean)
  • #===(object) ⇒ Boolean

    Returns:

    • (Boolean)
[View source]

3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
# File 'string.c', line 3396

VALUE
rb_str_equal(VALUE str1, VALUE str2)
{
    if (str1 == str2) return Qtrue;
    if (!RB_TYPE_P(str2, T_STRING)) {
	if (!rb_respond_to(str2, idTo_str)) {
	    return Qfalse;
	}
	return rb_equal(str2, str1);
    }
    return rb_str_eql_internal(str1, str2);
}