End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
String#casecmp?
casecmp?(other_string) → true, false, or nil
string.c
View on GitHub ↗
static VALUE
rb_str_casecmp_p(VALUE str1, VALUE str2)
{
VALUE s = rb_check_string_type(str2);
if (NIL_P(s)) {
return Qnil;
}
return str_casecmp_p(str1, s);
}
Returns true if self and other_string are equal after Unicode case folding, otherwise false:
Example
'foo'.casecmp?('foo') # => true 'foo'.casecmp?('food') # => false 'food'.casecmp?('foo') # => false 'FOO'.casecmp?('foo') # => true 'foo'.casecmp?('FOO') # => true
Returns nil if the two values are incomparable:
Example
'foo'.casecmp?(1) # => nil
See Case Mapping.
Related: String#casecmp.