Method: String#===

Defined in:
string.c

#==(obj) ⇒ Boolean #===(obj) ⇒ Boolean

Equality

Returns whether str == obj, similar to Object#==.

If obj is not an instance of String but responds to to_str, then the two strings are compared using case equality Object#===.

Otherwise, returns similarly to String#eql?, comparing length and content.

Overloads:

  • #==(obj) ⇒ Boolean

    Returns:

    • (Boolean)
  • #===(obj) ⇒ Boolean

    Returns:

    • (Boolean)


2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
# File 'string.c', line 2500

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, rb_intern("to_str"))) {
	    return Qfalse;
	}
	return rb_equal(str2, str1);
    }
    return str_eql(str1, str2);
}