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 obj.==.

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

Overloads:

  • #==(obj) ⇒ Boolean

    Returns:

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

    Returns:

    • (Boolean)


3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
# File 'string.c', line 3266

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);
}